SHARE
TWEET

Pretty Printing

Nolrai Sep 6th, 2019 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- Pretty printing of type expresions
  3. class Pretty p where
  4.   pprint :: (Applicative m, LFresh m) => p -> m Doc
  5.  
  6. instance Pretty Poly where
  7.   pprint (Poly p) =
  8.     lunbind $
  9.       \ (bindings, typeExpr) ->
  10.         do
  11.           vars <- pprintListSep (pure (PP.text ",")) bindings
  12.           printedExpr <- pprint typeExpr
  13.           pure $ PP.brackets a <+> PP.text "==>" <+> printedExpr
  14.  
  15. pprintListSep :: forall m. (LFresh m, Pretty a) => m Doc -> [a] -> m Doc
  16. pprintListSep l sep = foldr PP.empty f l
  17.   where
  18.     f a b = do
  19.       a' <- a
  20.      sep' <- sep
  21.       b' <- b
  22.      pure $ a <+> sep <+> b
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top