mirror of
https://github.com/github/semantic.git
synced 2025-01-05 14:11:33 +03:00
Add Show instances.
This commit is contained in:
parent
55bca5ed1e
commit
d5a59ff9b0
@ -7,6 +7,9 @@ data Cofree functor annotation = annotation :< (functor (Cofree functor annotati
|
||||
instance (Eq annotation, Eq (functor (Cofree functor annotation))) => Eq (Cofree functor annotation) where
|
||||
a :< f == b :< g = a == b && f == g
|
||||
|
||||
instance (Show annotation, Show (functor (Cofree functor annotation))) => Show (Cofree functor annotation) where
|
||||
showsPrec n (a :< f) = showsPrec n a . (" :< " ++) . showsPrec n f
|
||||
|
||||
unwrap :: Cofree functor annotation -> functor (Cofree functor annotation)
|
||||
unwrap (_ :< f) = f
|
||||
|
||||
|
@ -9,6 +9,10 @@ instance (Eq pure, Eq (functor (Free functor pure))) => Eq (Free functor pure) w
|
||||
Free f == Free g = f == g
|
||||
_ == _ = False
|
||||
|
||||
instance (Show pure, Show (functor (Free functor pure))) => Show (Free functor pure) where
|
||||
showsPrec n (Pure a) = ("Pure " ++) . showsPrec n a
|
||||
showsPrec n (Free f) = ("Free " ++) . showsPrec n f
|
||||
|
||||
iter :: Functor functor => (functor pure -> pure) -> Free functor pure -> pure
|
||||
iter _ (Pure a) = a
|
||||
iter f (Free g) = f (iter f <$> g)
|
||||
|
Loading…
Reference in New Issue
Block a user