Skip to content

Commit 73746d9

Browse files
committed
Fix purescript#2092, precedence of type application (purescript#2098)
* Fix purescript#2092, precedence of type application * one more test
1 parent fac68e5 commit 73746d9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

examples/passing/TypeOperators.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import A (type (~>), type (/\), (/\))
55
natty f. f ~> f
66
natty x = x
77

8+
data Compose f g a = Compose (f (g a))
9+
10+
testPrecedence1 f g. Compose f g ~> Compose f g
11+
testPrecedence1 x = x
12+
13+
testPrecedence2 f g. f ~> g f ~> g
14+
testPrecedence2 nat fx = nat fx
15+
816
swap a b. a /\ b b /\ a
917
swap (a /\ b) = b /\ a
1018

src/Language/PureScript/Parser/Types.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ parseConstrainedType = do
8282
parseAnyType :: TokenParser Type
8383
parseAnyType = P.buildExpressionParser operators (buildPostfixParser postfixTable parseTypeAtom) P.<?> "type"
8484
where
85-
operators = [ [ P.Infix (P.try (parseQualified (Op <$> symbol)) >>= \ident ->
85+
operators = [ [ P.Infix (return TypeApp) P.AssocLeft ]
86+
, [ P.Infix (P.try (parseQualified (Op <$> symbol)) >>= \ident ->
8687
return (BinaryNoParensType (TypeOp ident))) P.AssocRight
8788
]
88-
, [ P.Infix (return TypeApp) P.AssocLeft ]
8989
, [ P.Infix (rarrow >> return function) P.AssocRight ]
9090
]
9191
postfixTable = [ \t -> KindedType t <$> (indented *> doubleColon *> parseKind)

0 commit comments

Comments
 (0)