1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Define Traversable instances for Unions.

This commit is contained in:
Rob Rix 2017-04-24 13:37:59 -04:00
parent 09d4dbcb8e
commit 0ad31e7887

View File

@ -70,6 +70,14 @@ instance (Functor f, Functor (Union (g ': hs))) => Functor (Union (f ': g ': hs)
fmap f (There t) = There (fmap f t)
instance Traversable f => Traversable (Union '[f]) where
traverse f = fmap Here . traverse f . strengthen
instance (Traversable f, Traversable (Union (g ': hs))) => Traversable (Union (f ': g ': hs)) where
traverse f (Here r) = Here <$> traverse f r
traverse f (There t) = There <$> traverse f t
instance (Eq (f a), Eq (Union fs a)) => Eq (Union (f ': fs) a) where
Here f1 == Here f2 = f1 == f2
There fs1 == There fs2 = fs1 == fs2