diff options
| author | Richard Eisenberg <eir@cis.upenn.edu> | 2015-12-24 14:33:19 -0500 |
|---|---|---|
| committer | Richard Eisenberg <eir@cis.upenn.edu> | 2015-12-24 14:37:39 -0500 |
| commit | 2db18b8135335da2da9918b722699df684097be9 (patch) | |
| tree | 660dd90916aa6568694bbe39cdab83c7af98c5d7 /compiler/parser/Parser.y | |
| parent | 48db13d279d592ed3044cbaf3513854bcb0d3dce (diff) | |
| download | haskell-2db18b8135335da2da9918b722699df684097be9.tar.gz | |
Visible type application
This re-working of the typechecker algorithm is based on
the paper "Visible type application", by Richard Eisenberg,
Stephanie Weirich, and Hamidhasan Ahmed, to be published at
ESOP'16.
This patch introduces -XTypeApplications, which allows users
to say, for example `id @Int`, which has type `Int -> Int`. See
the changes to the user manual for details.
This patch addresses tickets #10619, #5296, #10589.
Diffstat (limited to 'compiler/parser/Parser.y')
| -rw-r--r-- | compiler/parser/Parser.y | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index ead81ac337..11dc84f0a6 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -414,6 +414,7 @@ output it generates. '-<<' { L _ (ITLarrowtail _) } -- for arrow notation '>>-' { L _ (ITRarrowtail _) } -- for arrow notation '.' { L _ ITdot } + TYPEAPP { L _ ITtypeApp } '{' { L _ ITocurly } -- special symbols '}' { L _ ITccurly } @@ -2237,7 +2238,11 @@ fexp :: { LHsExpr RdrName } aexp :: { LHsExpr RdrName } : qvar '@' aexp {% ams (sLL $1 $> $ EAsPat $1 $3) [mj AnnAt $2] } + -- If you change the parsing, make sure to understand + -- Note [Lexing type applications] in Lexer.x + | '~' aexp {% ams (sLL $1 $> $ ELazyPat $2) [mj AnnTilde $1] } + | TYPEAPP atype {% ams (sLL $1 $> $ HsType (mkHsWildCardBndrs $2)) [mj AnnAt $1] } | aexp1 { $1 } aexp1 :: { LHsExpr RdrName } @@ -2954,6 +2959,10 @@ var :: { Located RdrName } | '(' varsym ')' {% ams (sLL $1 $> (unLoc $2)) [mop $1,mj AnnVal $2,mcp $3] } + -- Lexing type applications depends subtly on what characters can possibly + -- end a qvar. Currently (June 2015), only $idchars and ")" can end a qvar. + -- If you're changing this, please see Note [Lexing type applications] in + -- Lexer.x. qvar :: { Located RdrName } : qvarid { $1 } | '(' varsym ')' {% ams (sLL $1 $> (unLoc $2)) |
