-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Combination of #1 and #2 #10
base: develop
Are you sure you want to change the base?
Conversation
Co-Authored-By: Alexandre Esteves <2335822+alexfmpe@users.noreply.github.com>
Do this without changing strictness using ~.
This makes it match the new PatchMapWithMove, and obviates PatchDMapWithReset.
This isn't good enough. I think there is a bug in that we don't store enough information in the two field: we need both inner patches with the join so we can combine them together. In the non-dependent case, nothing stops us from making this misake, but in the dependent case we would need to use a `Category` instance on the inner move patches. We plainly aren't combining two inner patches in the double move case, and the types let us know.
As described in d72221c I think all |
I'm not sure it is a good idea in general, so I am putting in another library instead.
src/Data/Monoid/DecidablyEmpty.hs
Outdated
module Data.Monoid.DecidablyEmpty where | ||
|
||
class Monoid a => DecidablyEmpty a where | ||
isNull :: a -> Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to conventions this should be either null
or isMempty
...
src/Data/Patch.hs
Outdated
unsafePatchDMapWithMove, weakenPatchDMapWithMoveWith) | ||
import Data.Patch.DMapWithMove as X | ||
( PatchDMapWithMove, const2PatchDMapWithMoveWith, mapPatchDMapWithMove | ||
, patchDMapWithMoveToPatchMapWithMoveWith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sprained my tongue :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(i have no suggestions though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a guid
negateG _ = Proxy | ||
_ ~~ _ = Proxy | ||
negateG ~Proxy = Proxy | ||
~Proxy ~~ ~Proxy = Proxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this actually necessary to be in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope
type PatchTarget p :: * | ||
class ( PatchHet p | ||
, PatchSource p ~ PatchTarget p | ||
) => Patch p where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the way you tied these two together, it should make life easier in a lot of cases.
src/Data/Patch/Class.hs
Outdated
apply (Identity a) _ = Just a | ||
|
||
-- | 'Proxy' can be used as a 'Patch' that always fully replaces the value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is wrong -- a 'Patch' that never alters the value?
src/Data/Patch/DMapWithMove.hs
Outdated
:: forall k v | ||
. (GCompare k, GShow k) | ||
=> DMap k (NodeInfo k v) | ||
-> Bool | ||
validPatchDMapWithMove = not . null . validationErrorsForPatchDMapWithMove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has anyone ever used this? the sense of the test looks reversed to me ...
src/Data/Patch/DMapWithMove.hs
Outdated
-- [ toAfter :=> Fixup_Delete ] | ||
-- _ -> | ||
[ toAfter :=> Fixup_Update (This $ From_Move $ fromBefore :=> (Flip $ p1 `o` p0)) | ||
, fromBefore :=> Fixup_Update (That $ To_Move $ toAfter :=> (p1 `o` p0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p1 o
p0 should be pulled out into a let to avoid recomputation
src/Data/Patch/DMapWithMove.hs
Outdated
moveDMapKey :: GCompare k => k a -> k a -> PatchDMapWithMove k v | ||
moveDMapKey | ||
:: GCompare k | ||
=> k a -> k a -> PatchDMapWithMove k (Proxy3 v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be generalized to any patchy Category pretty safely ...
src/Data/Patch/DMapWithMove.hs
Outdated
-- | Move the value from the given key @k a@ to this key. The target key | ||
-- should also have an entry in the patch giving the current key in | ||
-- @_nodeInfo_from@, usually but not necessarily with @To_Delete@. | ||
To_Move :: !(DSum k (p from)) -> To k p from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better actually, once the types have been verified as lining up, to force one of these to Proxy so there aren't two copies of the patch that can end up being unshared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what the original MapWithMove2
patch used to do, more or less. Maybe check out that PR. I couldn't get version to type check but perhaps I needed to just rebuild some values more to get things to type check.
src/Data/Patch/DMapWithMove/By.hs
Outdated
-- This type isn't used directly as the from field patch, but is instead wrapped | ||
-- in an existential. However, it is nice to be able to reason about this in | ||
-- isolation as it is itself a @Semigroupoid@ when the underlying patch is. | ||
data By (k :: a -> *) (p :: a -> a -> *) :: a -> a -> * where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this, how is it different from From?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference is no existentials and so has a Category instance.
It's not actually used at all; I made it in the process of figuring out what I was doing. I meant to call out that we probably should delete it but still keep it for the some review unless it helped anyone think about it too.
Should be made to include #14, and do something similar for a |
New one is called `DMapWithPatchingMove`
This is the one that doesn't store patches on the "to" side.
Now that it doesn't contain patches, it doesn't need so many params.
Credit to @xplat for the heterogeneous patch idea for use with dmap.