mirror of
https://github.com/github/semantic.git
synced 2024-12-21 13:51:44 +03:00
Define a Diffable' instance for NonEmpty fields in syntax.
This commit is contained in:
parent
07fda850f9
commit
2d6f130d32
@ -7,6 +7,7 @@ import Control.Monad.Free.Freer
|
||||
import Data.Function (on)
|
||||
import Data.Functor.Both
|
||||
import Data.Functor.Classes
|
||||
import Data.List.NonEmpty (NonEmpty(..))
|
||||
import Data.Maybe
|
||||
import Data.Proxy
|
||||
import Data.These
|
||||
@ -146,3 +147,9 @@ instance Diffable' U1 where
|
||||
-- | Diff two lists of parameters.
|
||||
instance Diffable' (Rec1 []) where
|
||||
algorithmFor' a b = fmap Rec1 <$> Just ((byRWS `on` unRec1) a b)
|
||||
|
||||
-- | Diff two non-empty lists of parameters.
|
||||
instance Diffable' (Rec1 NonEmpty) where
|
||||
algorithmFor' (Rec1 (a:|as)) (Rec1 (b:|bs)) = Just $ do
|
||||
d:ds <- byRWS (a:as) (b:bs)
|
||||
pure (Rec1 (d :| ds))
|
||||
|
Loading…
Reference in New Issue
Block a user