1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Add Unalign.

This commit is contained in:
Rob Rix 2016-03-22 09:39:03 -04:00
parent aabb2bbbd1
commit 7033571fca

View File

@ -58,3 +58,10 @@ instance Crosswalk Identity where
instance Crosswalk (Join These) where
crosswalk f = these (fmap (Join . This) . f) (fmap (Join . That) . f) (\ a b -> alignWith Join (f a) (f b)) . runJoin
class Align f => Unalign f where
unalign :: f (These a b) -> (f (Maybe a), f (Maybe b))
unalign x = (left <$> x, right <$> x)
where left = these Just (const Nothing) (curry (Just . fst))
right = these (const Nothing) Just (curry (Just . snd))