@@ -22,6 +22,7 @@ import PureScript.Types
2222import PureScript.Parser.Common
2323import Control.Applicative
2424import qualified Text.Parsec as P
25+import qualified Text.Parsec.Expr as P
2526import Control.Arrow (Arrow(..))
2627
2728parseNumber :: P.Parsec String P.Column Type
@@ -69,7 +70,11 @@ parsePolyType = PolyType <$> (P.option [] (indented *> reserved "forall" *> many
6970 <*> parseType
7071
7172parseType :: P.Parsec String P.Column Type
72−parseType = fold (lexeme parseTypeAtom) (lexeme parseTypeAtom) TypeApp
73+parseType = P.buildExpressionParser operators . buildPostfixParser postfixTable $ parseTypeAtom
74+ where
75+ postfixTable :: [P.Parsec String P.Column (Type -> Type)]
76+ postfixTable = [ flip TypeApp <$> parseTypeAtom ]
77+ operators = [ [ P.Infix (lexeme (P.try (P.string "->")) >> return (\t1 t2 -> Function [t1] t2)) P.AssocLeft ] ]
7378
7479parseNameAndType :: P.Parsec String P.Column (String, Type)
7580parseNameAndType = (,) <$> (indented *> identifier <* indented <* lexeme (P.string "::")) <*> parseType