@@ -37,7 +37,7 @@ data Type
37 = Lambda Type Type
37 = Lambda Type Type
38 | Var N.Name
38 | Var N.Name
39 | Type N.Name [Type]
39 | Type N.Name [Type]
40− | Record [(N.Name, Type)] (Maybe Type)
40+ | Record [(N.Name, Type)] (Maybe N.Name)
42 | Tuple Type Type [Type]
42 | Tuple Type Type [Type]
@@ -127,29 +127,31 @@ toDoc context tipe =
128 application
128 application
131− case flattenRecord tipe of
132− ([], Nothing) ->
130+ Record [] Nothing ->
133− P.text "{}"
131+ "{}"
133+ Record fields ext ->
135− (fields, Nothing) ->
135+ Nothing ->
137− [ P.cat (zipWith (<+>) ("{" : repeat ",") (map prettyField fields))
137+ [ P.cat (zipWith (<+>) ("{" : repeat ",") (map entryToDoc fields))
141− (fields, Just x) ->
141+ Just x ->
143− ("{" <+> P.text (N.toString x) <+> "|")
143+ ("{" <+> P.text (N.toString x) <+> "|")
146− [ P.sep (P.punctuate "," (map prettyField fields))
146+ [ P.sep (P.punctuate "," (map entryToDoc fields))
152+entryToDoc :: (N.Name, Type) -> P.Doc
151− prettyField (field, fieldType) =
153+entryToDoc (field, fieldType) =
152− P.text (N.toString field) <+> ":" <+> toDoc None fieldType
154+ P.text (N.toString field) <+> ":" <+> toDoc None fieldType
155collectLambdas :: Type -> [Type]
157collectLambdas :: Type -> [Type]
@@ -159,24 +161,6 @@ collectLambdas tipe =
159 _ -> [tipe]
161 _ -> [tipe]
162−flattenRecord :: Type -> ( [(N.Name, Type)], Maybe N.Name )
168− Record fields Nothing ->
171− Record fields (Just ext) ->
172− let (fields',ext') = flattenRecord ext
174− (fields' ++ fields, ext')
177− error "Trying to flatten ill-formed record."
181-- JSON for TYPE
165-- JSON for TYPE
@@ -225,7 +209,7 @@ fromRawType (A.At _ astType) =
225 let fromField (A.At _ field, tipe) = (field, fromRawType tipe) in
209 let fromField (A.At _ field, tipe) = (field, fromRawType tipe) in
227 (map fromField fields)
211 (map fromField fields)
228− (fmap fromRawType ext)
212+ (fmap A.toValue ext)