on master help sign in
Add pretty printing for record types
d9c1317Evan Czaplicki
compiler/SourceSyntax/Type.hs+4−1
@@ -41,7 +41,10 @@ instance Pretty Type where
41 | Help.isTuple name -> P.parens . P.sep . P.punctuate P.comma $ map pretty tipes
41 | Help.isTuple name -> P.parens . P.sep . P.punctuate P.comma $ map pretty tipes
42 | otherwise -> P.hang (P.text name) 2 (P.sep $ map prettyParens tipes)
42 | otherwise -> P.hang (P.text name) 2 (P.sep $ map prettyParens tipes)
43 EmptyRecord -> P.braces P.empty
43 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
45
48
46collectLambdas tipe =
49collectLambdas tipe =
47 case tipe of
50 case tipe of