Skip to content

Commit

Permalink
Fix #2092, precedence of type application (#2098)
Browse files Browse the repository at this point in the history
* Fix #2092, precedence of type application

* one more test
  • Loading branch information
paf31 committed May 8, 2016
1 parent fac68e5 commit 73746d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions examples/passing/TypeOperators.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import A (type (~>), type (/\), (/\))
natty f. f ~> f
natty x = x

data Compose f g a = Compose (f (g a))

testPrecedence1 f g. Compose f g ~> Compose f g
testPrecedence1 x = x

testPrecedence2 f g. f ~> g f ~> g
testPrecedence2 nat fx = nat fx

swap a b. a /\ b b /\ a
swap (a /\ b) = b /\ a

Expand Down
4 changes: 2 additions & 2 deletions src/Language/PureScript/Parser/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ parseConstrainedType = do
parseAnyType :: TokenParser Type
parseAnyType = P.buildExpressionParser operators (buildPostfixParser postfixTable parseTypeAtom) P.<?> "type"
where
operators = [ [ P.Infix (P.try (parseQualified (Op <$> symbol)) >>= \ident ->
operators = [ [ P.Infix (return TypeApp) P.AssocLeft ]
, [ P.Infix (P.try (parseQualified (Op <$> symbol)) >>= \ident ->
return (BinaryNoParensType (TypeOp ident))) P.AssocRight
]
, [ P.Infix (return TypeApp) P.AssocLeft ]
, [ P.Infix (rarrow >> return function) P.AssocRight ]
]
postfixTable = [ \t -> KindedType t <$> (indented *> doubleColon *> parseKind)
Expand Down

0 comments on commit 73746d9

Please sign in to comment.