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/rename | |
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/rename')
-rw-r--r-- | compiler/rename/RnExpr.hs | 13 | ||||
-rw-r--r-- | compiler/rename/RnSplice.hs | 4 | ||||
-rw-r--r-- | compiler/rename/RnTypes.hs | 3 |
3 files changed, 11 insertions, 9 deletions
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs index c4e5bb2abe..03f4b62043 100644 --- a/compiler/rename/RnExpr.hs +++ b/compiler/rename/RnExpr.hs @@ -298,9 +298,9 @@ rnExpr (HsMultiIf _ty alts) -- ; return (HsMultiIf ty alts', fvs) } ; return (HsMultiIf placeHolderType alts', fvs) } -rnExpr (HsType a) - = do { (t, fvT) <- rnLHsType HsTypeCtx a - ; return (HsType t, fvT) } +rnExpr (HsType ty) + = do { (ty', fvT) <- rnHsWcType HsTypeCtx ty + ; return (HsType ty', fvT) } rnExpr (ArithSeq _ _ seq) = do { opt_OverloadedLists <- xoptM LangExt.OverloadedLists @@ -524,7 +524,7 @@ rnCmd (HsCmdDo (L l stmts) _) rnStmts ArrowExpr rnLCmd stmts (\ _ -> return ((), emptyFVs)) ; return ( HsCmdDo (L l stmts') placeHolderType, fvs ) } -rnCmd cmd@(HsCmdCast {}) = pprPanic "rnCmd" (ppr cmd) +rnCmd cmd@(HsCmdWrap {}) = pprPanic "rnCmd" (ppr cmd) --------------------------------------------------- type CmdNeeds = FreeVars -- Only inhabitants are @@ -541,7 +541,7 @@ methodNamesCmd (HsCmdArrApp _arrow _arg _ HsFirstOrderApp _rtl) methodNamesCmd (HsCmdArrApp _arrow _arg _ HsHigherOrderApp _rtl) = unitFV appAName methodNamesCmd (HsCmdArrForm {}) = emptyFVs -methodNamesCmd (HsCmdCast _ cmd) = methodNamesCmd cmd +methodNamesCmd (HsCmdWrap _ cmd) = methodNamesCmd cmd methodNamesCmd (HsCmdPar c) = methodNamesLCmd c @@ -1819,7 +1819,8 @@ sectionErr expr patSynErr :: HsExpr RdrName -> RnM (HsExpr Name, FreeVars) patSynErr e = do { addErr (sep [ptext (sLit "Pattern syntax in expression context:"), - nest 4 (ppr e)]) + nest 4 (ppr e)] $$ + text "Did you mean to enable TypeApplications?") ; return (EWildPat, emptyFVs) } badIpBinds :: Outputable a => SDoc -> a -> SDoc diff --git a/compiler/rename/RnSplice.hs b/compiler/rename/RnSplice.hs index 8f87d730d8..9ddf132311 100644 --- a/compiler/rename/RnSplice.hs +++ b/compiler/rename/RnSplice.hs @@ -45,7 +45,7 @@ import Var ( Id ) import THNames ( quoteExpName, quotePatName, quoteDecName, quoteTypeName , decsQTyConName, expQTyConName, patQTyConName, typeQTyConName, ) -import {-# SOURCE #-} TcExpr ( tcMonoExpr ) +import {-# SOURCE #-} TcExpr ( tcPolyExpr ) import {-# SOURCE #-} TcSplice ( runMetaD, runMetaE, runMetaP, runMetaT, tcTopSpliceExpr ) #endif @@ -295,7 +295,7 @@ runRnSplice flavour run_meta ppr_res splice -- Typecheck the expression ; meta_exp_ty <- tcMetaTy meta_ty_name ; zonked_q_expr <- tcTopSpliceExpr Untyped $ - tcMonoExpr the_expr meta_exp_ty + tcPolyExpr the_expr meta_exp_ty -- Run the expression ; result <- run_meta zonked_q_expr diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index 52a164f105..5a58148170 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -751,7 +751,7 @@ checkExtraConstraintWildCard env wc = checkWildCard env mb_bad where mb_bad | not (extraConstraintWildCardsAllowed env) - = Just (ptext (sLit "Extra-contraint wildcard") <+> quotes (ppr wc) + = Just (ptext (sLit "Extra-constraint wildcard") <+> quotes (ppr wc) <+> ptext (sLit "not allowed")) | otherwise = Nothing @@ -774,6 +774,7 @@ wildCardsAllowed env RuleCtx {} -> True FamPatCtx {} -> True -- Not named wildcards though GHCiCtx {} -> True + HsTypeCtx {} -> True _ -> False rnAnonWildCard :: HsWildCardInfo RdrName -> RnM (HsWildCardInfo Name) |