Skip to content

Commit

Permalink
Add type signature to improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
quchen committed Jun 8, 2021
1 parent 2dbeaf5 commit 1f0bffe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions prettyprinter/src/Prettyprinter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
-- Let’s prettyprint a simple Haskell type definition. First, intersperse @->@
-- and add a leading @::@,
--
-- >>> let prettyType = align . sep . zipWith (<+>) ("::" : repeat "->")
-- >>> :{
-- >>> prettyprintType :: [Doc x] -> Doc x
-- >>> prettyprintType = align . sep . zipWith (<+>) ("::" : repeat "->")
-- >>> :}
--
-- The 'sep' function is one way of concatenating documents, there are multiple
-- others, e.g. 'vsep', 'cat' and 'fillSep'. In our case, 'sep' space-separates
Expand All @@ -47,11 +50,11 @@
--
-- Second, prepend the name to the type,
--
-- >>> let prettyDecl n tys = pretty n <+> prettyType tys
-- >>> let prettyprintDeclaration n tys = pretty n <+> prettyprintType tys
--
-- Now we can define a document that contains some type signature:
--
-- >>> let doc = prettyDecl "example" ["Int", "Bool", "Char", "IO ()"]
-- >>> let doc = prettyprintDeclaration "example" ["Int", "Bool", "Char", "IO ()"]
--
-- This document can now be printed, and it automatically adapts to available
-- space. If the page is wide enough (80 characters in this case), the
Expand Down

0 comments on commit 1f0bffe

Please sign in to comment.