mirror of
https://github.com/github/semantic.git
synced 2024-11-24 00:42:33 +03:00
Remove all the parentheses ever.
This commit is contained in:
parent
4f84059c0b
commit
313019fa3a
16
src/Diff.hs
16
src/Diff.hs
@ -16,22 +16,22 @@ data Patch a = Patch { old :: Maybe a, new :: Maybe a }
|
||||
type Diff a = Free (Syntax a) (Patch (Term a Info))
|
||||
|
||||
(</>) :: Maybe (Term a Info) -> Maybe (Term a Info) -> Diff a
|
||||
(</>) a b = Pure $ Patch { old = a, new = b }
|
||||
(</>) a b = Pure Patch { old = a, new = b }
|
||||
|
||||
a :: Term String Info
|
||||
a = Info :< (Keyed $ fromList [
|
||||
("hello", Info :< (Indexed [ Info :< (Leaf "hi") ])),
|
||||
("goodbye", Info :< (Leaf "goodbye")) ])
|
||||
("hello", Info :< Indexed [ Info :< Leaf "hi" ]),
|
||||
("goodbye", Info :< Leaf "goodbye") ])
|
||||
|
||||
b :: Term String Info
|
||||
b = Info :< (Keyed $ fromList [
|
||||
("hello", Info :< (Indexed [])),
|
||||
("goodbye", Info :< (Indexed [])) ])
|
||||
("hello", Info :< Indexed []),
|
||||
("goodbye", Info :< Indexed []) ])
|
||||
|
||||
d :: Diff String
|
||||
d = Free $ Keyed $ fromList [
|
||||
("hello", Free $ Indexed [ Just (Info :< (Leaf "hi")) </> Nothing ]),
|
||||
("goodbye", Just (Info :< (Leaf "goodbye")) </> Just (Info :< (Indexed []))) ]
|
||||
("hello", Free $ Indexed [ Just (Info :< Leaf "hi") </> Nothing ]),
|
||||
("goodbye", Just (Info :< Leaf "goodbye") </> Just (Info :< Indexed [])) ]
|
||||
|
||||
data Operation a f
|
||||
= Recur (Term a Info) (Term a Info) (Diff a -> f)
|
||||
@ -43,7 +43,7 @@ type Algorithm a = Free (Operation a)
|
||||
cost :: Diff a -> Integer
|
||||
cost f = iter c $ fmap g f where
|
||||
c (Leaf _) = 0
|
||||
c (Keyed xs) = sum $ snd <$> (toList xs)
|
||||
c (Keyed xs) = sum $ snd <$> toList xs
|
||||
c (Indexed xs) = sum xs
|
||||
c (Fixed xs) = sum xs
|
||||
g _ = 1
|
||||
|
Loading…
Reference in New Issue
Block a user