git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #634
b8090a3Phil Freeman
examples/passing/EmptyRow.pursnew file+8
@@ -0,0 +1,8 @@
1+module Main where
2+
3+data Foo r = Foo { | r }
4+
5+test :: Foo ()
6+test = Foo {}
7+
8+main = Debug.Trace.trace "Done"
src/Language/PureScript/Parser/Types.hs+4−5
@@ -40,7 +40,7 @@ parseFunction :: P.Parsec String ParseState Type
40parseFunction = parens $ P.try (lexeme (P.string "->")) >> return tyFunction
40parseFunction = parens $ P.try (lexeme (P.string "->")) >> return tyFunction
41
41
42parseObject :: P.Parsec String ParseState Type
42parseObject :: P.Parsec String ParseState Type
43−parseObject = braces $ TypeApp tyObject <$> parseRow False
43+parseObject = braces $ TypeApp tyObject <$> parseRow
44
44
45parseTypeVariable :: P.Parsec String ParseState Type
45parseTypeVariable :: P.Parsec String ParseState Type
46parseTypeVariable = do
46parseTypeVariable = do
@@ -67,7 +67,7 @@ parseTypeAtom = indented *> P.choice (map P.try
67 , parseTypeVariable
67 , parseTypeVariable
68 , parseTypeConstructor
68 , parseTypeConstructor
69 , parseForAll
69 , parseForAll
70− , parens (parseRow True)
70+ , parens parseRow
71 , parens parsePolyType ])
71 , parens parsePolyType ])
72
72
73parseConstrainedType :: P.Parsec String ParseState Type
73parseConstrainedType :: P.Parsec String ParseState Type
@@ -111,6 +111,5 @@ parseNameAndType p = (,) <$> (indented *> (identifier <|> stringLiteral) <* inde
111parseRowEnding :: P.Parsec String ParseState Type
111parseRowEnding :: P.Parsec String ParseState Type
112parseRowEnding = P.option REmpty (TypeVar <$> (lexeme (indented *> P.char '|') *> indented *> identifier))
112parseRowEnding = P.option REmpty (TypeVar <$> (lexeme (indented *> P.char '|') *> indented *> identifier))
113
113
114−parseRow :: Bool -> P.Parsec String ParseState Type
114+parseRow :: P.Parsec String ParseState Type
115−parseRow nonEmpty = (curry rowFromList <$> many' (parseNameAndType parsePolyType) <*> parseRowEnding) P.<?> "row"
115+parseRow = (curry rowFromList <$> commaSep (parseNameAndType parsePolyType) <*> parseRowEnding) P.<?> "row"
116− where many' = if nonEmpty then commaSep1 else commaSep