+%
+% (c) The University of Glasgow 2006
+%
- Module for type coercions, as in System FC.
+Module for type coercions, as in System FC.
Coercions are represented as types, and their kinds tell what types the
coercion works on.
#include "HsVersions.h"
import TypeRep
-import Type ( Type, Kind, PredType, substTyWith, mkAppTy, mkForAllTy,
- mkFunTy, splitAppTy_maybe, splitForAllTy_maybe, coreView,
- kindView, mkTyConApp, isCoercionKind, isEqPred, mkAppTys,
- coreEqType, splitAppTys, isTyVarTy, splitTyConApp_maybe
- )
-import TyCon ( TyCon, tyConArity, mkCoercionTyCon, isClosedNewTyCon,
- newTyConRhs, newTyConCo_maybe,
- isCoercionTyCon, isCoercionTyCon_maybe )
-import Var ( Var, TyVar, isTyVar, tyVarKind )
-import Name ( BuiltInSyntax(..), Name, mkWiredInName, tcName )
-import OccName ( mkOccNameFS )
-import PrelNames ( symCoercionTyConKey,
- transCoercionTyConKey, leftCoercionTyConKey,
- rightCoercionTyConKey, instCoercionTyConKey,
- unsafeCoercionTyConKey, gHC_PRIM
- )
-import Util ( lengthIs, snocView )
-import Unique ( hasKey )
-import BasicTypes ( Arity )
+import Type
+import TyCon
+import Var
+import Name
+import OccName
+import PrelNames
+import Util
+import Unique
+import BasicTypes
import Outputable
-
------------------------------
decomposeCo :: Arity -> Coercion -> [Coercion]
-- (decomposeCo 3 c) = [right (left (left c)), right (left c), right c]
splitCoercionKind_maybe (PredTy (EqPred ty1 ty2)) = Just (ty1, ty2)
splitCoercionKind_maybe other = Nothing
-isCoVar :: Var -> Bool
-isCoVar tv = isTyVar tv && isCoercionKind (tyVarKind tv)
-
type Coercion = Type
type CoercionKind = Kind -- A CoercionKind is always of form (ty1 :=: ty2)
-- ...and their names
mkCoConName occ key coCon = mkWiredInName gHC_PRIM (mkOccNameFS tcName occ)
- key Nothing (ATyCon coCon) BuiltInSyntax
+ key (ATyCon coCon) BuiltInSyntax
transCoercionTyConName = mkCoConName FSLIT("trans") transCoercionTyConKey transCoercionTyCon
symCoercionTyConName = mkCoConName FSLIT("sym") symCoercionTyConKey symCoercionTyCon