[remove HsNewTypeDecl in favor of re-using existing HsDataDecl, clean up code as a result.
John Meacham <john@repetae.net>**20120311030703
 Ignore-this: 2b50fff95eeca8295050be2eff84b82
] hunk ./src/DataConstructors.hs 555
-    f decl@HsNewTypeDecl {} = g decl
+--    f decl@HsNewTypeDecl {} = g decl
hunk ./src/DataConstructors.hs 579
-        newtypeDeps = [ (n,concatMap (fm . hsBangType) $ hsConDeclArgs c) | HsNewTypeDecl { hsDeclName = n, hsDeclCon = c } <- ds  ]
+        newtypeDeps = [ (n,concatMap (fm . hsBangType) $ hsConDeclArgs c) |
+            HsDataDecl { hsDeclDeclType = DeclTypeNewtype, hsDeclName = n, hsDeclCons = (head -> c) } <- ds ]
hunk ./src/DataConstructors.hs 584
-    f decl@HsNewTypeDecl {  hsDeclName = nn, hsDeclCon = c } =
-        dt decl (if nn `elem` newtypeLoopBreakers then RecursiveAlias else ErasedAlias)  [c]
-    f decl@HsDataDecl { hsDeclKindDecl = True } = dkind decl
-    f decl@HsDataDecl { hsDeclCons = cs } = dt decl NotAlias  cs
+    f decl@HsDataDecl { hsDeclDeclType = DeclTypeNewtype,  hsDeclName = nn, hsDeclCons = cs } =
+        dt decl (if nn `elem` newtypeLoopBreakers then RecursiveAlias else ErasedAlias) cs
+    f decl@HsDataDecl { hsDeclDeclType = DeclTypeKind } = dkind decl
+    f decl@HsDataDecl { hsDeclCons = cs } = dt decl NotAlias cs
hunk ./src/DataConstructors.hs 636
+    dkind _ = error "dkind passed bad decl"
hunk ./src/DerivingDrift/Drift.hs 30
-driftDerive' (HsNewTypeDecl sloc cntxt name args condecl derives) = do
-        let d =  unrenameTyVars $ toData  name args [condecl] derives
-        xs <- return $ map (derive False d) derives
-        return $ unlines xs
+--driftDerive' (HsNewTypeDecl sloc cntxt name args condecl derives) = do
+--        let d =  unrenameTyVars $ toData  name args [condecl] derives
+--        xs <- return $ map (derive False d) derives
+--        return $ unlines xs
hunk ./src/FrontEnd/DataConsAssump.hs 62
-dataDeclEnv modName kt (HsNewTypeDecl _sloc context typeName args condecl _)
-   = conDeclType modName kt preds resultType condecl
-   where
-   typeName' = toName TypeConstructor typeName
-   typeKind = kindOf typeName' kt
-   resultType = foldl tAp tycon argVars
-   tycon = TCon (Tycon typeName' typeKind)
-   argVars = map fromHsNameToTyVar $ zip argKinds args
-   argKinds = init $ unfoldKind typeKind
-   fromHsNameToTyVar :: (Kind, HsName) -> Type
-   fromHsNameToTyVar (k, n)
-      = TVar (tyvar (toName TypeVal n) k)
-   preds = hsContextToPreds kt context
+--dataDeclEnv modName kt (HsNewTypeDecl _sloc context typeName args condecl _)
+--   = conDeclType modName kt preds resultType condecl
+--   where
+--   typeName' = toName TypeConstructor typeName
+--   typeKind = kindOf typeName' kt
+--   resultType = foldl tAp tycon argVars
+--   tycon = TCon (Tycon typeName' typeKind)
+--   argVars = map fromHsNameToTyVar $ zip argKinds args
+--   argKinds = init $ unfoldKind typeKind
+--   fromHsNameToTyVar :: (Kind, HsName) -> Type
+--   fromHsNameToTyVar (k, n)
+--      = TVar (tyvar (toName TypeVal n) k)
+--   preds = hsContextToPreds kt context
hunk ./src/FrontEnd/HsErrors.hs 54
-    f TopLevel HsNewTypeDecl { hsDeclSrcLoc = sl, hsDeclDerives = ds' } = do
-        let ds = map (toName ClassName) ds'
-        checkDeriving sl True ds
-        return ()
+--    f TopLevel HsNewTypeDecl { hsDeclSrcLoc = sl, hsDeclDerives = ds' } = do
+--        let ds = map (toName ClassName) ds'
+--        checkDeriving sl True ds
+--        return ()
hunk ./src/FrontEnd/HsErrors.hs 66
-    f context decl@HsNewTypeDecl {} = warn (srcLoc decl) InvalidDecl $ "newtype declaration not allowed " ++ show context
+--    f context decl@HsNewTypeDecl {} = warn (srcLoc decl) InvalidDecl $ "newtype declaration not allowed " ++ show context
hunk ./src/FrontEnd/HsParser.y 66
-      PRAGMAEXP { PragmaExp $$ }
+      PRAGMACTYPE { PragmaExp "CTYPE" }
hunk ./src/FrontEnd/HsParser.y 321
-                         returnP hsDataDecl { hsDeclKindDecl = True, hsDeclSrcLoc = $4, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $7, hsDeclCons = reverse $6 } }
+                         returnP hsDataDecl { hsDeclDeclType = DeclTypeKind, hsDeclSrcLoc = $4, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $7, hsDeclCons = reverse $6 } }
hunk ./src/FrontEnd/HsParser.y 324
-                         returnP (HsNewTypeDecl $3 cs c t $5 $6) }
+                         returnP hsNewTypeDecl { hsDeclSrcLoc = $3, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclCons = [$5], hsDeclDerives = $6} }
hunk ./src/FrontEnd/HsParser.y 412
-pragmaexp  :: { Located HsPragmaExp }
-      : PRAGMAEXP srcloc texps srcloc PRAGMAEND
-        { located ($2,$4) $ HsPragmaExp $1 $3 }
+--pragmaexp  :: { Located HsPragmaExp }
+--      : PRAGMAEXP srcloc texps srcloc PRAGMAEND
+--        { located ($2,$4) $ HsPragmaExp $1 $3 }
hunk ./src/FrontEnd/HsPretty.hs 23
-import Char
+import Data.Char
hunk ./src/FrontEnd/HsPretty.hs 207
-
hunk ./src/FrontEnd/HsPretty.hs 252
-ppHsDecl HsDataDecl { hsDeclContext = context, hsDeclName = name, hsDeclArgs = nameList, hsDeclCons = constrList, hsDeclDerives = derives } =
-	   --blankline $
-           mySep ([text "data", ppHsContext context, ppHsName name]
-                  ++ map ppHsName nameList)
+ppHsDecl HsDataDecl { .. } = ans where
+    ans = mySep ([declType, ppHsContext hsDeclContext, ppHsName hsDeclName]
+                  ++ map ppHsName hsDeclArgs)
hunk ./src/FrontEnd/HsPretty.hs 256
-                                           (map ppHsConstr constrList))
-                       $$$ ppHsDeriving derives)
+                                           (map ppHsConstr hsDeclCons))
+                       $$$ ppHsDeriving hsDeclDerives)
+    declType = case hsDeclDeclType of
+        DeclTypeKind    -> text "data kind"
+        DeclTypeData    -> text "data"
+        DeclTypeNewtype -> text "newtype"
hunk ./src/FrontEnd/HsPretty.hs 263
-ppHsDecl (HsNewTypeDecl pos context name nameList constr derives) =
-	   --blankline $
-           mySep ([text "newtype", ppHsContext context, ppHsName name]
-                  ++ map ppHsName nameList)
-                  <+> equals <+> (ppHsConstr constr
-                                  $$$ ppHsDeriving derives)
---m{spacing=False}
hunk ./src/FrontEnd/HsSyn.hs 83
-    srcLoc HsNewTypeDecl  { hsDeclSrcLoc = sl } = sl
hunk ./src/FrontEnd/HsSyn.hs 101
-    hsDeclKindDecl = False,
+    hsDeclDeclType = DeclTypeData,
hunk ./src/FrontEnd/HsSyn.hs 111
-hsNewTypeDecl = HsNewTypeDecl {
-    hsDeclSrcLoc = bogusASrcLoc,
-    hsDeclContext = [],
-    hsDeclName = error "hsNewTypeDecl.hsDeclName",
-    hsDeclArgs = [],
-    hsDeclCon = error "hsNewTypeDecl.hsDeclCon",
-    hsDeclDerives = []
+hsNewTypeDecl = hsDataDecl {
+    hsDeclDeclType = DeclTypeNewtype,
+    hsDeclName = error "hsNewTypeDecl.hsDeclName"
hunk ./src/FrontEnd/HsSyn.hs 116
+data DeclType = DeclTypeData | DeclTypeNewtype | DeclTypeKind
+    deriving(Eq,Show)
+
hunk ./src/FrontEnd/HsSyn.hs 130
-        hsDeclTArgs   :: [HsType],
+        hsDeclTArgs  :: [HsType],
hunk ./src/FrontEnd/HsSyn.hs 134
-        hsDeclKindDecl :: !Bool,
+        hsDeclDeclType :: !DeclType,
hunk ./src/FrontEnd/HsSyn.hs 143
-    | HsNewTypeDecl {
-        hsDeclSrcLoc  :: SrcLoc,
-        hsDeclContext :: HsContext,
-        hsDeclName    :: HsName,
-        hsDeclArgs    :: [Name],
-        hsDeclCon     :: HsConDecl,
-        {- deriving -} hsDeclDerives :: [HsName]
-        }
hunk ./src/FrontEnd/KindInfer.hs 399
-    f HsDataDecl { hsDeclKindDecl = True, .. } = kiDataKind hsDeclName hsDeclCons
+    f HsDataDecl { hsDeclDeclType = DeclTypeKind, .. } = kiDataKind hsDeclName hsDeclCons
hunk ./src/FrontEnd/KindInfer.hs 410
+    f HsDataDecl { hsDeclDeclType = DeclTypeNewtype, .. } = kiAlias hsDeclContext hsDeclName hsDeclArgs (head hsDeclCons)
hunk ./src/FrontEnd/KindInfer.hs 412
-    f HsNewTypeDecl { .. } = kiAlias hsDeclContext hsDeclName hsDeclArgs hsDeclCon
hunk ./src/FrontEnd/Rename.hs 127
-
hunk ./src/FrontEnd/Rename.hs 143
-checkExportSpec e = f e  where
-    f (HsEVar n) = do check [Val] n
-    f (HsEAbs n) = do check [DataConstructor,TypeConstructor,ClassName] n
-    f (HsEThingAll n) = do check [DataConstructor,TypeConstructor,ClassName] n
-    f (HsEThingWith n ns) = do
-        check [DataConstructor,TypeConstructor,ClassName] n
+checkExportSpec e = f [DataConstructor, TypeConstructor, ClassName] e where
+    f _ (HsEVar n) = do check [Val] n
+    f dt (HsEAbs n) = do check dt n
+    f dt (HsEThingAll n) = do check dt n
+    f dt (HsEThingWith n ns) = do
+        check dt n
hunk ./src/FrontEnd/Rename.hs 150
-    f HsEModuleContents {} = return ()
+    f _ HsEModuleContents {} = return ()
+    f _ (HsEQualified nt he) = f [nt] he
hunk ./src/FrontEnd/Rename.hs 189
-    g HsNewTypeDecl { hsDeclSrcLoc = sloc, hsDeclCon = c } = createSelectors sloc [c]
hunk ./src/FrontEnd/Rename.hs 219
-    f HsDataDecl { .. } | hsDeclKindDecl = do
+    f HsDataDecl { .. } | hsDeclDeclType == DeclTypeKind = do
hunk ./src/FrontEnd/Rename.hs 250
-    f (HsNewTypeDecl srcLoc hsContext hsName hsNames1 hsConDecl hsNames2) = do
-        hsName' <- renameTypeName hsName
-        updateWith (map fromTypishHsName hsNames1) $ do
-            hsContext' <- rename hsContext
-            hsNames1' <- mapM renameTypeName hsNames1 -- TODO
-            hsConDecl' <- rename hsConDecl
-            hsNames2' <- mapM (renameName . toName ClassName) hsNames2
-            return (HsNewTypeDecl srcLoc hsContext' hsName' hsNames1' hsConDecl' hsNames2')
hunk ./src/FrontEnd/Rename.hs 740
-    f HsDataDecl { hsDeclKindDecl = True, hsDeclSrcLoc =sl, hsDeclName = n, hsDeclCons = cs } = do
+    f HsDataDecl { hsDeclDeclType = DeclTypeKind, hsDeclSrcLoc =sl, hsDeclName = n, hsDeclCons = cs } = do
hunk ./src/FrontEnd/Rename.hs 746
-    f (HsNewTypeDecl sl _ n _ c _) = do tellF $ (toName TypeConstructor n,sl,snub [ x |(x,_,_) <- cs']): cs' ; zup [c] where
-        cs' = namesHsConDecl' toName c
hunk ./src/FrontEnd/Tc/Module.hs 107
-    f HsNewTypeDecl { hsDeclCon = (hsConDeclName -> cn)  } = return $ DatNewT cn
+    f HsDataDecl { hsDeclDeclType = DeclTypeNewtype, hsDeclCons = (hsConDeclName . head -> cn)  } = return $ DatNewT cn
hunk ./src/FrontEnd/Tc/Module.hs 141
-    let classAndDataDecls = filter (or' [isHsDataDecl, isHsNewTypeDecl, isHsClassDecl, isHsClassAliasDecl]) ds
+    let classAndDataDecls = filter (or' [isHsDataDecl, isHsClassDecl, isHsClassAliasDecl]) ds
hunk ./src/FrontEnd/TypeSyns.hs 121
-
-renameHsDecl (HsNewTypeDecl srcLoc hsContext hsName hsNames1 hsConDecl hsNames2) subTable = withSrcLoc srcLoc $ do
-    hsContext' <- renameHsContext hsContext subTable
-    hsConDecl' <- renameHsConDecl hsConDecl subTable
-    return (HsNewTypeDecl srcLoc hsContext' hsName hsNames1 hsConDecl' hsNames2)
hunk ./src/FrontEnd/Utils.hs 16
+maybeGetDeclName HsDataDecl { hsDeclDeclType = DeclTypeKind, hsDeclName } = return (toName SortName hsDeclName)
hunk ./src/FrontEnd/Utils.hs 18
-maybeGetDeclName HsNewTypeDecl { hsDeclName = name } = return (toName TypeConstructor name)