X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypes%2FTyCon.lhs;h=e6366bea2b01d9b2f9ff10fc938b984f5128cb82;hb=a1515d75e38a32d69636c98bb590f6195e2ab3d1;hp=88a620978e341f39e54fa67fb15436b825dbeca4;hpb=39dbcf69ffa6842bf541ccf18e2ec4a11cb6cceb;p=ghc-hetmet.git diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index 88a6209..e6366be 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -11,7 +11,7 @@ module TyCon( PrimRep(..), tyConPrimRep, - sizeofPrimRep, + primRepSizeW, AlgTyConRhs(..), visibleDataCons, TyConParent(..), @@ -186,7 +186,7 @@ data TyCon tyConName :: Name, tyConArity :: Arity, coKindFun :: [Type] -> (Type,Type) - } -- INVARAINT: coKindFun is always applied to exactly 'arity' args + } -- INVARIANT: coKindFun is always applied to exactly 'arity' args -- E.g. for trans (c1 :: ta=tb) (c2 :: tb=tc), the coKindFun returns -- the kind as a pair of types: (ta,tc) @@ -372,7 +372,7 @@ Source code: w2 :: Foo T w2 = MkFoo (\(MkT x) -> case w1 of MkFoo f -> f x) -After desugaring, and discading the data constructors for the newtypes, +After desugaring, and discarding the data constructors for the newtypes, we get: w2 :: Foo T w2 = w1 @@ -455,19 +455,22 @@ data PrimRep | AddrRep -- a pointer, but not to a Haskell value | FloatRep | DoubleRep - deriving( Eq ) - --- Size of a PrimRep, in bytes -sizeofPrimRep :: PrimRep -> Int -sizeofPrimRep IntRep = wORD_SIZE -sizeofPrimRep WordRep = wORD_SIZE -sizeofPrimRep Int64Rep = wORD64_SIZE -sizeofPrimRep Word64Rep= wORD64_SIZE -sizeofPrimRep FloatRep = 4 -sizeofPrimRep DoubleRep= 8 -sizeofPrimRep AddrRep = wORD_SIZE -sizeofPrimRep PtrRep = wORD_SIZE -sizeofPrimRep VoidRep = 0 + deriving( Eq, Show ) + +instance Outputable PrimRep where + ppr r = text (show r) + +-- Size of a PrimRep, in words +primRepSizeW :: PrimRep -> Int +primRepSizeW IntRep = 1 +primRepSizeW WordRep = 1 +primRepSizeW Int64Rep = wORD64_SIZE `quot` wORD_SIZE +primRepSizeW Word64Rep= wORD64_SIZE `quot` wORD_SIZE +primRepSizeW FloatRep = 1 -- NB. might not take a full word +primRepSizeW DoubleRep= dOUBLE_SIZE `quot` wORD_SIZE +primRepSizeW AddrRep = 1 +primRepSizeW PtrRep = 1 +primRepSizeW VoidRep = 0 \end{code} %************************************************************************