on master help sign in
Add pretty printing for record types
commitd9c1317a2579993b78522260c6af023e2cdd0527 authorEvan Czaplicki <info@elm-lang.org> dateThu 25 Jul 2013, 17:09 (13 years ago) parent11c1b76
1 file changed+4−1
compiler/SourceSyntax/Type.hs+4−1
compiler/SourceSyntax/Type.hs+4−1
@@ -41,7 +41,10 @@ instance Pretty Type where
4141 | Help.isTuple name -> P.parens . P.sep . P.punctuate P.comma $ map pretty tipes
4242 | otherwise -> P.hang (P.text name) 2 (P.sep $ map prettyParens tipes)
4343 EmptyRecord -> P.braces P.empty
44− Record fields ext -> error "not done yet"
44+ Record fields ext -> P.braces $ P.hang (pretty ext <+> P.text "|") 4 prettyFields
45+ where
46+ prettyField (f,ts) = map (\t -> P.text f <+> P.text ":" <+> pretty t) ts
47+ prettyFields = commaSep . concatMap prettyField $ Map.toList fields
4548
4649collectLambdas tipe =
4750 case tipe of