mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
🔥 patchSum.
This commit is contained in:
parent
987dcb7839
commit
da5bdac3d8
@ -5,7 +5,6 @@ module Patch
|
||||
, after
|
||||
, before
|
||||
, unPatch
|
||||
, patchSum
|
||||
, maybeFst
|
||||
, maybeSnd
|
||||
, mapPatch
|
||||
@ -47,10 +46,6 @@ mapPatch f _ (Delete a ) = Delete (f a)
|
||||
mapPatch _ g (Insert b) = Insert (g b)
|
||||
mapPatch f g (Replace a b) = Replace (f a) (g b)
|
||||
|
||||
-- | Calculate the cost of the patch given a function to compute the cost of a item.
|
||||
patchSum :: (a -> Int) -> Patch a -> Int
|
||||
patchSum termCost patch = maybe 0 termCost (before patch) + maybe 0 termCost (after patch)
|
||||
|
||||
-- | Return Just the value in This, or the first value in These, if any.
|
||||
maybeFst :: These a b -> Maybe a
|
||||
maybeFst = these Just (const Nothing) ((Just .) . const)
|
||||
|
Loading…
Reference in New Issue
Block a user