git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2299 from purescript/phil/parser-issue

Fix weird parser issue identified by @FrigoEU

commit350774104d9411bb73dfee0f391f120876df4ec9 authorPhil Freeman <paf31@cantab.net> dateThu 8 Sep 2016, 11:11 (10 years ago) parent0f5305296596d5
2 files changed+11−4
examples/passing/ConstraintParsingIssue.purs+9 src/Language/PureScript/Parser/Types.hs+2−4
examples/passing/ConstraintParsingIssue.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import Control.Monad.Eff.Console
4+
5+class X a
6+
7+instance x :: X (Array (Array a)) => X (Array a)
8+
9+main = log "Done"
src/Language/PureScript/Parser/Types.hs+2−4
@@ -54,8 +54,7 @@ parseForAll = mkForAll <$> ((reserved "forall" <|> reserved "∀") *> P.many1 (i
5454--
5555parseTypeAtom :: TokenParser Type
5656parseTypeAtom = indented *> P.choice
57− [ P.try parseConstrainedType
58− , P.try parseFunction
57+ [ P.try parseFunction
5958 , parseTypeLevelString
6059 , parseObject
6160 , parseTypeWildcard
@@ -81,9 +80,8 @@ parseConstrainedType = do
8180 ty <- P.many parseTypeAtom
8281 return (Constraint className ty Nothing)
8382
84−
8583parseAnyType :: TokenParser Type
86−parseAnyType = P.buildExpressionParser operators (buildPostfixParser postfixTable parseTypeAtom) P.<?> "type"
84+parseAnyType = P.buildExpressionParser operators (buildPostfixParser postfixTable (P.try parseConstrainedType <|> parseTypeAtom)) P.<?> "type"
8785 where
8886 operators = [ [ P.Infix (return TypeApp) P.AssocLeft ]
8987 , [ P.Infix (P.try (parseQualified parseOperator) >>= \ident ->