X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypes%2FGenerics.lhs;h=604db8d2d9594d50da71c94bb38883e0fbab2014;hb=ced4c13ea3577e01556a2f76c2cc458c0be6c83c;hp=5494999b57ae7a3f52285d12361f4db3c6574826;hpb=ab22f4e6456820c1b5169d75f5975a94e61f54ce;p=ghc-hetmet.git diff --git a/compiler/types/Generics.lhs b/compiler/types/Generics.lhs index 5494999..604db8d 100644 --- a/compiler/types/Generics.lhs +++ b/compiler/types/Generics.lhs @@ -3,6 +3,13 @@ % \begin{code} +{-# OPTIONS -fno-warn-incomplete-patterns #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module Generics ( canDoGenerics, mkTyConGenericBinds, mkGenericRhs, validGenericInstanceType, validGenericMethodType @@ -11,13 +18,11 @@ module Generics ( canDoGenerics, mkTyConGenericBinds, import HsSyn import Type -import TcHsSyn import TcType import DataCon import TyCon import Name -import OccName import RdrName import BasicTypes import Var @@ -385,12 +390,13 @@ splitInHalf list = (left, right) mkGenericLocal :: US -> RdrName mkGenericLocal u = mkVarUnqual (mkFastString ("g" ++ show u)) +mkGenericNames :: TyCon -> (RdrName, RdrName) mkGenericNames tycon = (from_RDR, to_RDR) where tc_name = tyConName tycon tc_occ = nameOccName tc_name - tc_mod = nameModule tc_name + tc_mod = ASSERT( isExternalName tc_name ) nameModule tc_name from_RDR = mkOrig tc_mod (mkGenOcc1 tc_occ) to_RDR = mkOrig tc_mod (mkGenOcc2 tc_occ) \end{code} @@ -525,6 +531,7 @@ bimapTyCon tycon arg_eps ------------------- -- bimapArrow :: [EP a a', EP b b'] -> EP (a->b) (a'->b') +bimapArrow :: [EP (LHsExpr RdrName)] -> EP (LHsExpr RdrName) bimapArrow [ep1, ep2] = EP { fromEP = mkHsLam [nlVarPat a_RDR, nlVarPat b_RDR] from_body, toEP = mkHsLam [nlVarPat a_RDR, nlVarPat b_RDR] to_body } @@ -534,25 +541,30 @@ bimapArrow [ep1, ep2] ------------------- -- bimapTuple :: [EP a1 b1, ... EP an bn] -> EP (a1,...an) (b1,..bn) +bimapTuple :: [EP (LHsExpr RdrName)] -> EP (LHsExpr RdrName) bimapTuple eps - = EP { fromEP = mkHsLam [noLoc tuple_pat] (noLoc from_body), - toEP = mkHsLam [noLoc tuple_pat] (noLoc to_body) } + = EP { fromEP = mkHsLam [noLoc tuple_pat] from_body, + toEP = mkHsLam [noLoc tuple_pat] to_body } where names = takeList eps gs_RDR tuple_pat = TuplePat (map nlVarPat names) Boxed placeHolderType eps_w_names = eps `zip` names - to_body = ExplicitTuple [toEP ep `mkHsApp` nlHsVar g | (ep,g) <- eps_w_names] Boxed - from_body = ExplicitTuple [fromEP ep `mkHsApp` nlHsVar g | (ep,g) <- eps_w_names] Boxed + to_body = mkLHsTupleExpr [toEP ep `mkHsApp` nlHsVar g | (ep,g) <- eps_w_names] + from_body = mkLHsTupleExpr [fromEP ep `mkHsApp` nlHsVar g | (ep,g) <- eps_w_names] ------------------- -- bimapList :: EP a b -> EP [a] [b] +bimapList :: [EP (LHsExpr RdrName)] -> EP (LHsExpr RdrName) bimapList [ep] = EP { fromEP = nlHsApp (nlHsVar map_RDR) (fromEP ep), toEP = nlHsApp (nlHsVar map_RDR) (toEP ep) } ------------------- -a_RDR = mkVarUnqual FSLIT("a") -b_RDR = mkVarUnqual FSLIT("b") +a_RDR, b_RDR :: RdrName +a_RDR = mkVarUnqual (fsLit "a") +b_RDR = mkVarUnqual (fsLit "b") + +gs_RDR :: [RdrName] gs_RDR = [ mkVarUnqual (mkFastString ("g"++show i)) | i <- [(1::Int) .. ] ] idEP :: EP (LHsExpr RdrName)