import Data.Generics
import Data.List (elemIndex)
+import Data.Char
data Module
= Module AnMname [Tdef] [Vdefg]
-- either type constructors or coercion names onto either
-- kinds or coercion kinds.
data KindOrCoercion = Kind Kind | Coercion CoercionKind
-
+
data Lit = Literal CoreLit Ty
deriving (Data, Typeable, Eq)
primPkg = P $ zEncodeString "ghc-prim"
ghcPrefix = ["GHC"]
mainPrefix = []
-baseMname = mkBaseMname "Base"
+baseMname = error "Somebody called baseMname!" -- mkBaseMname "Base"
boolMname = mkPrimMname "Bool"
mainVar = qual mainMname "main"
wrapperMainVar = qual wrapperMainMname "main"
isUtupleTy :: Ty -> Bool
isUtupleTy (Tapp t _) = isUtupleTy t
-isUtupleTy (Tcon tc) = tc `elem` [tcUtuple n | n <- [1..maxUtuple]]
+isUtupleTy (Tcon tc) =
+ case tc of
+ (Just pm, 'Z':rest) | pm == primMname && last rest == 'H' ->
+ let mid = take ((length rest) - 1) rest in
+ all isDigit mid && (let num = read mid in
+ 1 <= num && num <= maxUtuple)
+ _ -> False
+-- The above is ugly, but less ugly than this:
+--tc `elem` [tcUtuple n | n <- [1..maxUtuple]]
isUtupleTy _ = False
dcUtuple :: Int -> Qual Dcon
flattenBinds (Nonrec vd : binds) = vd : flattenBinds binds
flattenBinds (Rec prs1 : binds) = prs1 ++ flattenBinds binds
flattenBinds [] = []
+
+unitMname :: AnMname
+unitMname = mkPrimMname "Unit"