mirror of
https://github.com/github/semantic.git
synced 2024-12-18 20:31:55 +03:00
Extract union pretty-printing to the top level.
This commit is contained in:
parent
053954cc97
commit
a16c6e4f75
@ -57,6 +57,9 @@ unTerm (a :< f) = a :<< f
|
||||
hoistCofree :: Functor f => (forall a. f a -> g a) -> Term f a -> Term g a
|
||||
hoistCofree f = go where go (a :< r) = a :< f (fmap go r)
|
||||
|
||||
liftPrettyUnion :: Apply1 Pretty1 fs => (a -> Doc ann) -> ([a] -> Doc ann) -> Union fs a -> Doc ann
|
||||
liftPrettyUnion p pl = apply1 (Proxy :: Proxy Pretty1) (liftPretty p pl)
|
||||
|
||||
instance Pretty1 f => Pretty1 (Term f) where
|
||||
liftPretty p pl = go where go (a :< f) = p a <+> liftPretty go (Pretty.list . map (liftPretty p pl)) f
|
||||
|
||||
@ -64,7 +67,7 @@ instance (Pretty1 f, Pretty a) => Pretty (Term f a) where
|
||||
pretty = liftPretty pretty prettyList
|
||||
|
||||
instance Apply1 Pretty1 fs => Pretty1 (Union fs) where
|
||||
liftPretty p pl = apply1 (Proxy :: Proxy Pretty1) (liftPretty p pl)
|
||||
liftPretty = liftPrettyUnion
|
||||
|
||||
type instance Base (Term f a) = TermF f a
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user