diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-05-27 15:26:46 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-06-15 14:41:49 +0100 |
commit | 77bb09270c70455bbd547470c4e995707d19f37d (patch) | |
tree | 3dbd57122d9931d2766fa32df0a4a29731f02d2a /compiler/prelude | |
parent | e33ca0e54f3c20a8b233a3f7b38e4968a4955300 (diff) | |
download | haskell-77bb09270c70455bbd547470c4e995707d19f37d.tar.gz |
Re-add FunTy (big patch)
With TypeInType Richard combined ForAllTy and FunTy, but that was often
awkward, and yielded little benefit becuase in practice the two were
always treated separately. This patch re-introduces FunTy. Specfically
* New type
data TyVarBinder = TvBndr TyVar VisibilityFlag
This /always/ has a TyVar it. In many places that's just what
what we want, so there are /lots/ of TyBinder -> TyVarBinder changes
* TyBinder still exists:
data TyBinder = Named TyVarBinder | Anon Type
* data Type = ForAllTy TyVarBinder Type
| FunTy Type Type
| ....
There are a LOT of knock-on changes, but they are all routine.
The Haddock submodule needs to be updated too
Diffstat (limited to 'compiler/prelude')
-rw-r--r-- | compiler/prelude/TysPrim.hs | 14 | ||||
-rw-r--r-- | compiler/prelude/TysWiredIn.hs | 15 |
2 files changed, 14 insertions, 15 deletions
diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index 1850e55b7d..e0be093420 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -682,7 +682,7 @@ mkProxyPrimTy k ty = TyConApp proxyPrimTyCon [k, ty] proxyPrimTyCon :: TyCon proxyPrimTyCon = mkPrimTyCon proxyPrimTyConName binders res_kind [Nominal,Nominal] - where binders = [ Named kv Specified + where binders = [ Named (TvBndr kv Specified) , Anon k ] res_kind = tYPE voidRepDataConTy kv = kKiVar @@ -699,8 +699,8 @@ proxyPrimTyCon = mkPrimTyCon proxyPrimTyConName binders res_kind [Nominal,Nomina eqPrimTyCon :: TyCon -- The representation type for equality predicates -- See Note [The equality types story] eqPrimTyCon = mkPrimTyCon eqPrimTyConName binders res_kind roles - where binders = [ Named kv1 Specified - , Named kv2 Specified + where binders = [ Named (TvBndr kv1 Specified) + , Named (TvBndr kv2 Specified) , Anon k1 , Anon k2 ] res_kind = tYPE voidRepDataConTy @@ -714,8 +714,8 @@ eqPrimTyCon = mkPrimTyCon eqPrimTyConName binders res_kind roles -- interpreted in coercionRole eqReprPrimTyCon :: TyCon -- See Note [The equality types story] eqReprPrimTyCon = mkPrimTyCon eqReprPrimTyConName binders res_kind roles - where binders = [ Named kv1 Specified - , Named kv2 Specified + where binders = [ Named (TvBndr kv1 Specified) + , Named (TvBndr kv2 Specified) , Anon k1 , Anon k2 ] res_kind = tYPE voidRepDataConTy @@ -730,8 +730,8 @@ eqReprPrimTyCon = mkPrimTyCon eqReprPrimTyConName binders res_kind roles eqPhantPrimTyCon :: TyCon eqPhantPrimTyCon = mkPrimTyCon eqPhantPrimTyConName binders res_kind [Nominal, Nominal, Phantom, Phantom] - where binders = [ Named kv1 Specified - , Named kv2 Specified + where binders = [ Named (TvBndr kv1 Specified) + , Named (TvBndr kv2 Specified) , Anon k1 , Anon k2 ] res_kind = tYPE voidRepDataConTy diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs index 5613d86749..82c5bfb389 100644 --- a/compiler/prelude/TysWiredIn.hs +++ b/compiler/prelude/TysWiredIn.hs @@ -130,7 +130,6 @@ import Type import DataCon import {-# SOURCE #-} ConLike import TyCon -import TyCoRep ( TyBinder(..) ) import Class ( Class, mkClass ) import RdrName import Name @@ -353,7 +352,7 @@ anyTyCon = mkFamilyTyCon anyTyConName binders res_kind [kKiVar] Nothing Nothing NotInjective where - binders = [Named kKiVar Specified] + binders = [mkNamedBinder (mkTyVarBinder Specified kKiVar)] res_kind = mkTyVarTy kKiVar anyTy :: Type @@ -496,8 +495,8 @@ pcDataConWithFixity' declared_infix dc_name wrk_key rri tyvars ex_tyvars arg_tys data_con = mkDataCon dc_name declared_infix prom_info (map (const no_bang) arg_tys) [] -- No labelled fields - tyvars (mkNamedBinders Specified tyvars) - ex_tyvars (mkNamedBinders Specified ex_tyvars) + (mkTyVarBinders Specified tyvars) + (mkTyVarBinders Specified ex_tyvars) [] -- No equality spec [] -- No theta arg_tys (mkTyConApp tycon (mkTyVarTys tyvars)) @@ -758,7 +757,7 @@ mk_tuple boxity arity = (tycon, tuple_con) in ( UnboxedTuple , gHC_PRIM - , mkNamedBinders Specified rr_tvs ++ + , map (mkNamedBinder . mkTyVarBinder Specified) rr_tvs ++ map (mkAnonBinder . tyVarKind) open_tvs , unboxedTupleKind , arity * 2 @@ -819,8 +818,8 @@ heqSCSelId, coercibleSCSelId :: Id klass = mkClass tvs [] [sc_pred] [sc_sel_id] [] [] (mkAnd []) tycon datacon = pcDataCon heqDataConName tvs [sc_pred] tycon - binders = [ mkNamedBinder Specified kv1 - , mkNamedBinder Specified kv2 + binders = [ mkNamedBinder (mkTyVarBinder Specified kv1) + , mkNamedBinder (mkTyVarBinder Specified kv2) , mkAnonBinder k1 , mkAnonBinder k2 ] kv1:kv2:_ = drop 9 alphaTyVars -- gets "j" and "k" @@ -843,7 +842,7 @@ heqSCSelId, coercibleSCSelId :: Id klass = mkClass tvs [] [sc_pred] [sc_sel_id] [] [] (mkAnd []) tycon datacon = pcDataCon coercibleDataConName tvs [sc_pred] tycon - binders = [ mkNamedBinder Specified kKiVar + binders = [ mkNamedBinder (mkTyVarBinder Specified kKiVar) , mkAnonBinder k , mkAnonBinder k ] k = mkTyVarTy kKiVar |