1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Add an Align instance for lists.

This commit is contained in:
Rob Rix 2016-03-07 09:42:53 -05:00
parent 05fa8a6aa5
commit 63782505af

View File

@ -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