summaryrefslogtreecommitdiff
path: root/compiler/types/IParam.lhs
diff options
context:
space:
mode:
authorMax Bolingbroke <batterseapower@hotmail.com>2011-09-06 17:22:47 +0100
committerMax Bolingbroke <batterseapower@hotmail.com>2011-09-06 20:48:41 +0100
commit9729fe7c3e54597ccf29c43c8c8ad0eaa2402ced (patch)
tree1ad67ec5008c8f30a7a8a01fa44cb35b9ce619d4 /compiler/types/IParam.lhs
parentb98267adc04266e0001019fb17746be570cc79ae (diff)
downloadhaskell-9729fe7c3e54597ccf29c43c8c8ad0eaa2402ced.tar.gz
Implement -XConstraintKind
Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact, this patch adds a new kind Constraint such that: Show :: * -> Constraint (?x::Int) :: Constraint (Int ~ a) :: Constraint And you can write *any* type with kind Constraint to the left of (=>): even if that type is a type synonym, type variable, indexed type or so on. The following (somewhat related) changes are also made: 1. We now box equality evidence. This is required because we want to give (Int ~ a) the *lifted* kind Constraint 2. For similar reasons, implicit parameters can now only be of a lifted kind. (?x::Int#) => ty is now ruled out 3. Implicit parameter constraints are now allowed in superclasses and instance contexts (this just falls out as OK with the new constraint solver) Internally the following major changes were made: 1. There is now no PredTy in the Type data type. Instead GHC checks the kind of a type to figure out if it is a predicate 2. There is now no AClass TyThing: we represent classes as TyThings just as a ATyCon (classes had TyCons anyway) 3. What used to be (~) is now pretty-printed as (~#). The box constructor EqBox :: (a ~# b) -> (a ~ b) 4. The type LCoercion is used internally in the constraint solver and type checker to represent coercions with free variables of type (a ~ b) rather than (a ~# b)
Diffstat (limited to 'compiler/types/IParam.lhs')
-rw-r--r--compiler/types/IParam.lhs41
1 files changed, 41 insertions, 0 deletions
diff --git a/compiler/types/IParam.lhs b/compiler/types/IParam.lhs
new file mode 100644
index 0000000000..67d46c3a82
--- /dev/null
+++ b/compiler/types/IParam.lhs
@@ -0,0 +1,41 @@
+%
+% (c) The University of Glasgow 2006
+% (c) The GRASP/AQUA Project, Glasgow University, 1998
+%
+
+\begin{code}
+module IParam (
+ ipFastString, ipTyConName, ipTyCon, ipCoAxiom
+ ) where
+
+#include "HsVersions.h"
+
+import Name
+import TyCon (CoAxiom, TyCon, newTyConCo_maybe)
+import Type
+
+import BasicTypes (IPName(..), ipNameName)
+import FastString
+import Outputable
+\end{code}
+
+\begin{code}
+ipFastString :: IPName Name -> FastString
+ipFastString = occNameFS . nameOccName . ipTyConName
+
+ipTyConName :: IPName Name -> Name
+ipTyConName = ipNameName
+
+ipTyCon :: IPName Name -> TyCon
+ipTyCon ip = case wiredInNameTyThing_maybe (ipTyConName ip) of
+ Just (ATyCon tc) -> tc
+ _ -> pprPanic "ipTyCon" (ppr ip)
+
+ipCoAxiom :: IPName Name -> CoAxiom
+ipCoAxiom ip = case newTyConCo_maybe (ipTyCon ip) of
+ Just ax -> ax
+ _ -> pprPanic "ipCoAxiom" (ppr ip)
+
+-- The IParam DataCon never gets any code generated for it, so it's
+-- a bit dangerous to actually make use of it, hence no ipDataCon function
+\end{code}