mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Add an Align instance for lists.
This commit is contained in:
parent
05fa8a6aa5
commit
63782505af
@ -6,3 +6,9 @@ class Functor f => Align f where
|
||||
align a b = alignWith id a b
|
||||
alignWith :: (These a b -> c) -> f a -> f b -> f c
|
||||
alignWith f a b = f <$> align a b
|
||||
|
||||
instance Align [] where
|
||||
nil = []
|
||||
alignWith f as [] = f . This <$> as
|
||||
alignWith f [] bs = f . That <$> bs
|
||||
alignWith f (a : as) (b : bs) = f (These a b) : alignWith f as bs
|
||||
|
Loading…
Reference in New Issue
Block a user