@@ -22,6 +22,7 @@ import PureScript.Types
22import PureScript.Parser.Common
22import PureScript.Parser.Common
23import Control.Applicative
23import Control.Applicative
24import qualified Text.Parsec as P
24import qualified Text.Parsec as P
25+import qualified Text.Parsec.Expr as P
25import Control.Arrow (Arrow(..))
26import Control.Arrow (Arrow(..))
27parseNumber :: P.Parsec String P.Column Type
28parseNumber :: P.Parsec String P.Column Type
@@ -69,7 +70,11 @@ parsePolyType = PolyType <$> (P.option [] (indented *> reserved "forall" *> many
69 <*> parseType
70 <*> parseType
71parseType :: P.Parsec String P.Column Type
72parseType :: P.Parsec String P.Column Type
72−parseType = fold (lexeme parseTypeAtom) (lexeme parseTypeAtom) TypeApp
73+parseType = P.buildExpressionParser operators . buildPostfixParser postfixTable $ parseTypeAtom
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 ] ]
74parseNameAndType :: P.Parsec String P.Column (String, Type)
79parseNameAndType :: P.Parsec String P.Column (String, Type)
75parseNameAndType = (,) <$> (indented *> identifier <* indented <* lexeme (P.string "::")) <*> parseType
80parseNameAndType = (,) <$> (indented *> identifier <* indented <* lexeme (P.string "::")) <*> parseType