@@ -16,6 +16,7 @@ import Guid
1616data ParseType = VarPT String
1717 | LambdaPT ParseType ParseType
1818 | ADTPT String [ParseType]
19+ | RecordPT [(String,ParseType)]
1920
2021listPT t = ADTPT "List" [t]
2122tuplePT ts = ADTPT ("Tuple" ++ show (length ts)) ts
@@ -30,8 +31,14 @@ typeTuple :: IParser ParseType
3031typeTuple = do ts <- parens (commaSep typeExpr)
3132 return $ case ts of { [t] -> t ; _ -> tuplePT ts }
3233
34+typeRecord :: IParser ParseType
35+typeRecord = fmap RecordPT . brackets . commaSep $ do
36+ lbl <- rLabel
37+ whitespace >> string "::" >> whitespace
38+ (,) lbl <$> typeExpr
39+
3340typeUnambiguous :: IParser ParseType
34−typeUnambiguous = typeList <|> typeTuple
41+typeUnambiguous = typeList <|> typeTuple <|> typeRecord
3542
3643typeSimple :: IParser ParseType
3744typeSimple = dealias <$> var
@@ -80,6 +87,8 @@ toDatatype name args tcs = Datatype name [1..n] <$> mapM toC tcs
8087 Just v -> Right v
8188 Nothing -> Left $ msg x
8289 | otherwise = return $ ADT x []
90+ toT (RecordPT fs) = do fs' <- mapM (\(x,pt) -> (,) x <$> toT pt) fs
91+ return (RecordT (recordT fs') EmptyRecord)
8392 msg x = "Type variable '" ++ x ++
8493 "' is unbound in type constructor '" ++ name ++ "'."
8594