Skip to content

Commit

Permalink
Merge pull request #14 from 414owen/os/pretty-records
Browse files Browse the repository at this point in the history
feat: Use vsep to make records legible
  • Loading branch information
phile314 authored Jul 17, 2024
2 parents b12ae79 + a81b06e commit f984c5c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Pinch/Generate/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ instance Pretty Deriving where

instance Pretty ConDecl where
pretty (ConDecl n args) = hsep $ [ pretty n ] ++ map pretty args
pretty (RecConDecl n args) = hsep $ [ pretty n, "{", fields, "}" ]
where fields = cList $ map (\(f, v) -> pretty f <+> "::" <+> pretty v) args
pretty (RecConDecl n fields) = pretty n
<> case fields of
[] -> "{}"
((f, t) : xs) -> line
<> "{" <+> pretty f <+> "::" <+> pretty t
<> line
<> vsep (map (\(f', v) -> "," <+> pretty f' <+> "::" <+> pretty v) xs)
<> line
<> "}"

instance Pretty InstHead where
pretty (InstHead cs n ty) = "instance" <> context <+> pretty n <+> pretty ty <+> "where"
Expand Down

0 comments on commit f984c5c

Please sign in to comment.