Use OPTIONS rather than OPTIONS_GHC for pragmas
[ghc-hetmet.git] / compiler / deSugar / DsMeta.hs
index 3c526ec..7fbce31 100644 (file)
 -- a Royal Pain (triggers other recompilation).
 -----------------------------------------------------------------------------
 
+{-# OPTIONS -w #-}
+-- 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/CodingStyle#Warnings
+-- for details
 
 module DsMeta( dsBracket, 
               templateHaskellNames, qTyConName, nameTyConName,
@@ -33,7 +39,6 @@ import qualified Language.Haskell.TH as TH
 import HsSyn
 import Class
 import PrelNames
-import OccName
 -- To avoid clashes with DsMeta.varName we must make a local alias for
 -- OccName.varName we do this by removing varName from the import of
 -- OccName above, making a qualified instance of OccName and using
@@ -42,10 +47,8 @@ import qualified OccName
 
 import Module
 import Id
-import OccName
 import Name
 import NameEnv
-import Type
 import TcType
 import TyCon
 import TysWiredIn
@@ -530,11 +533,11 @@ repE e@(ExplicitPArr ty es) = notHandled "Parallel arrays" (ppr e)
 repE e@(ExplicitTuple es boxed) 
   | isBoxed boxed         = do { xs <- repLEs es; repTup xs }
   | otherwise            = notHandled "Unboxed tuples" (ppr e)
-repE (RecordCon c _ (HsRecordBinds flds))
+repE (RecordCon c _ flds)
  = do { x <- lookupLOcc c;
         fs <- repFields flds;
         repRecCon x fs }
-repE (RecordUpd e (HsRecordBinds flds) _ _)
+repE (RecordUpd e flds _ _ _)
  = do { x <- repLE e;
         fs <- repFields flds;
         repRecUpd x fs }
@@ -616,12 +619,12 @@ repGuards other
                 g <- repPatGE (nonEmptyCoreList ss') rhs'
                 return (gs, g)
 
-repFields :: [(Located Name, LHsExpr Name)] -> DsM (Core [TH.Q TH.FieldExp])
-repFields flds = do
-        fnames <- mapM lookupLOcc (map fst flds)
-        es <- mapM repLE (map snd flds)
-        fs <- zipWithM repFieldExp fnames es
-        coreList fieldExpQTyConName fs
+repFields :: HsRecordBinds Name -> DsM (Core [TH.Q TH.FieldExp])
+repFields (HsRecFields { rec_flds = flds })
+  = do { fnames <- mapM lookupLOcc (map hsRecFieldId flds)
+       ; es <- mapM repLE (map hsRecFieldArg flds)
+       ; fs <- zipWithM repFieldExp fnames es
+       ; coreList fieldExpQTyConName fs }
 
 
 -----------------------------------------------------------------------------
@@ -704,8 +707,8 @@ rep_val_binds (ValBindsOut binds sigs)
  = do { core1 <- rep_binds' (unionManyBags (map snd binds))
       ;        core2 <- rep_sigs' sigs
       ;        return (core1 ++ core2) }
-rep_val_binds (ValBindsOut binds sigs)
- = panic "rep_val_binds: ValBindsOut"
+rep_val_binds (ValBindsIn binds sigs)
+ = panic "rep_val_binds: ValBindsIn"
 
 rep_binds :: LHsBinds Name -> DsM [Core TH.DecQ]
 rep_binds binds = do { binds_w_locs <- rep_binds' binds
@@ -817,9 +820,10 @@ repP (TuplePat ps _ _) = do { qs <- repLPs ps; repPtup qs }
 repP (ConPatIn dc details)
  = do { con_str <- lookupLOcc dc
       ; case details of
-         PrefixCon ps   -> do { qs <- repLPs ps; repPcon con_str qs }
-         RecCon pairs -> do { vs <- sequence $ map lookupLOcc (map hsRecFieldId pairs)
-                            ; ps <- sequence $ map repLP (map hsRecFieldArg pairs)
+         PrefixCon ps -> do { qs <- repLPs ps; repPcon con_str qs }
+         RecCon rec   -> do { let flds = rec_flds rec
+                           ; vs <- sequence $ map lookupLOcc (map hsRecFieldId flds)
+                            ; ps <- sequence $ map repLP (map hsRecFieldArg flds)
                             ; fps <- zipWithM (\x y -> rep2 fieldPatName [unC x,unC y]) vs ps
                             ; fps' <- coreList fieldPatQTyConName fps
                             ; repPrec con_str fps' }
@@ -1188,15 +1192,15 @@ repProto (MkC s) (MkC ty) = rep2 sigDName [s, ty]
 repCtxt :: Core [TH.TypeQ] -> DsM (Core TH.CxtQ)
 repCtxt (MkC tys) = rep2 cxtName [tys]
 
-repConstr :: Core TH.Name -> HsConDetails Name (LBangType Name)
+repConstr :: Core TH.Name -> HsConDeclDetails Name
           -> DsM (Core TH.ConQ)
 repConstr con (PrefixCon ps)
     = do arg_tys  <- mapM repBangTy ps
          arg_tys1 <- coreList strictTypeQTyConName arg_tys
          rep2 normalCName [unC con, unC arg_tys1]
 repConstr con (RecCon ips)
-    = do arg_vs   <- mapM lookupLOcc (map hsRecFieldId ips)
-         arg_tys  <- mapM repBangTy (map hsRecFieldArg ips)
+    = do arg_vs   <- mapM lookupLOcc (map cd_fld_name ips)
+         arg_tys  <- mapM repBangTy (map cd_fld_type ips)
          arg_vtys <- zipWithM (\x y -> rep2 varStrictTypeName [unC x, unC y])
                               arg_vs arg_tys
          arg_vtys' <- coreList varStrictTypeQTyConName arg_vtys