= do { con1 <- lookupOcc con ; -- See note [Binders and occurrences]
repConstr con1 details }
-repBangTy :: BangType Name -> DsM (Core (M.Q (M.Strictness, M.Typ)))
+repBangTy :: BangType Name -> DsM (Core (M.StrictTypQ))
repBangTy (BangType str ty) = do MkC s <- rep2 strName []
MkC t <- repTy ty
rep2 strictTypeName [s, t]
; clause <- repClause ps1 gs ds
; wrapGenSyns (ss1++ss2) clause }}}
-repGuards :: [GRHS Name] -> DsM (Core M.RightHandSideQ)
+repGuards :: [GRHS Name] -> DsM (Core M.RHSQ)
repGuards [GRHS [ResultStmt e loc] loc2]
= do {a <- repE e; repNormal a }
repGuards other
-- The helper function repSts computes the translation of each sub expression
-- and a bunch of prefix bindings denoting the dynamic renaming.
-repSts :: [Stmt Name] -> DsM ([GenSymBind], [Core M.StatementQ])
+repSts :: [Stmt Name] -> DsM ([GenSymBind], [Core M.StmtQ])
repSts [ResultStmt e loc] =
do { a <- repE e
; e1 <- repNoBindSt a
repCaseE :: Core M.ExpQ -> Core [M.MatchQ] -> DsM( Core M.ExpQ)
repCaseE (MkC e) (MkC ms) = rep2 caseEName [e, ms]
-repDoE :: Core [M.StatementQ] -> DsM (Core M.ExpQ)
+repDoE :: Core [M.StmtQ] -> DsM (Core M.ExpQ)
repDoE (MkC ss) = rep2 doEName [ss]
-repComp :: Core [M.StatementQ] -> DsM (Core M.ExpQ)
+repComp :: Core [M.StmtQ] -> DsM (Core M.ExpQ)
repComp (MkC ss) = rep2 compName [ss]
repListExp :: Core [M.ExpQ] -> DsM (Core M.ExpQ)
repSectionR (MkC x) (MkC y) = rep2 sectionRName [x,y]
------------ Right hand sides (guarded expressions) ----
-repGuarded :: Core [(M.ExpQ, M.ExpQ)] -> DsM (Core M.RightHandSideQ)
+repGuarded :: Core [(M.ExpQ, M.ExpQ)] -> DsM (Core M.RHSQ)
repGuarded (MkC pairs) = rep2 guardedName [pairs]
-repNormal :: Core M.ExpQ -> DsM (Core M.RightHandSideQ)
+repNormal :: Core M.ExpQ -> DsM (Core M.RHSQ)
repNormal (MkC e) = rep2 normalName [e]
-------------- Statements -------------------
-repBindSt :: Core M.Pat -> Core M.ExpQ -> DsM (Core M.StatementQ)
+------------- Stmts -------------------
+repBindSt :: Core M.Pat -> Core M.ExpQ -> DsM (Core M.StmtQ)
repBindSt (MkC p) (MkC e) = rep2 bindStName [p,e]
-repLetSt :: Core [M.DecQ] -> DsM (Core M.StatementQ)
+repLetSt :: Core [M.DecQ] -> DsM (Core M.StmtQ)
repLetSt (MkC ds) = rep2 letStName [ds]
-repNoBindSt :: Core M.ExpQ -> DsM (Core M.StatementQ)
+repNoBindSt :: Core M.ExpQ -> DsM (Core M.StmtQ)
repNoBindSt (MkC e) = rep2 noBindStName [e]
-------------- DotDot (Arithmetic sequences) -----------
repFromThenTo (MkC x) (MkC y) (MkC z) = rep2 fromThenToName [x,y,z]
------------ Match and Clause Tuples -----------
-repMatch :: Core M.Pat -> Core M.RightHandSideQ -> Core [M.DecQ] -> DsM (Core M.MatchQ)
+repMatch :: Core M.Pat -> Core M.RHSQ -> Core [M.DecQ] -> DsM (Core M.MatchQ)
repMatch (MkC p) (MkC bod) (MkC ds) = rep2 matchName [p, bod, ds]
-repClause :: Core [M.Pat] -> Core M.RightHandSideQ -> Core [M.DecQ] -> DsM (Core M.ClauseQ)
+repClause :: Core [M.Pat] -> Core M.RHSQ -> Core [M.DecQ] -> DsM (Core M.ClauseQ)
repClause (MkC ps) (MkC bod) (MkC ds) = rep2 clauseName [ps, bod, ds]
-------------- Dec -----------------------------
-repVal :: Core M.Pat -> Core M.RightHandSideQ -> Core [M.DecQ] -> DsM (Core M.DecQ)
+repVal :: Core M.Pat -> Core M.RHSQ -> Core [M.DecQ] -> DsM (Core M.DecQ)
repVal (MkC p) (MkC b) (MkC ds) = rep2 valName [p, b, ds]
repFun :: Core String -> Core [M.ClauseQ] -> DsM (Core M.DecQ)
mk_known_key_name space str uniq
= mkKnownKeyExternalName thModule (mkOccFS space str) uniq
-intPrimLName = varQual FSLIT("intPrimL") intPrimLIdKey
-floatPrimLName = varQual FSLIT("floatPrimL") floatPrimLIdKey
-doublePrimLName = varQual FSLIT("doublePrimL") doublePrimLIdKey
-integerLName = varQual FSLIT("integerL") integerLIdKey
-charLName = varQual FSLIT("charL") charLIdKey
-stringLName = varQual FSLIT("stringL") stringLIdKey
-rationalLName = varQual FSLIT("rationalL") rationalLIdKey
-plitName = varQual FSLIT("plit") plitIdKey
-pvarName = varQual FSLIT("pvar") pvarIdKey
-ptupName = varQual FSLIT("ptup") ptupIdKey
-pconName = varQual FSLIT("pcon") pconIdKey
-ptildeName = varQual FSLIT("ptilde") ptildeIdKey
-paspatName = varQual FSLIT("paspat") paspatIdKey
-pwildName = varQual FSLIT("pwild") pwildIdKey
-precName = varQual FSLIT("prec") precIdKey
-varName = varQual FSLIT("var") varIdKey
-conName = varQual FSLIT("con") conIdKey
-litName = varQual FSLIT("lit") litIdKey
-appName = varQual FSLIT("app") appIdKey
-infixEName = varQual FSLIT("infixE") infixEIdKey
-lamName = varQual FSLIT("lam") lamIdKey
-tupName = varQual FSLIT("tup") tupIdKey
-doEName = varQual FSLIT("doE") doEIdKey
-compName = varQual FSLIT("comp") compIdKey
+intPrimLName = varQual FSLIT("intPrimLit") intPrimLIdKey
+floatPrimLName = varQual FSLIT("floatPrimLit") floatPrimLIdKey
+doublePrimLName = varQual FSLIT("doublePrimLit") doublePrimLIdKey
+integerLName = varQual FSLIT("integerLit") integerLIdKey
+charLName = varQual FSLIT("charLit") charLIdKey
+stringLName = varQual FSLIT("stringLit") stringLIdKey
+rationalLName = varQual FSLIT("rationalLit") rationalLIdKey
+plitName = varQual FSLIT("litPat") plitIdKey
+pvarName = varQual FSLIT("varPat") pvarIdKey
+ptupName = varQual FSLIT("tupPat") ptupIdKey
+pconName = varQual FSLIT("conPat") pconIdKey
+ptildeName = varQual FSLIT("tildePat") ptildeIdKey
+paspatName = varQual FSLIT("asPat") paspatIdKey
+pwildName = varQual FSLIT("wildPat") pwildIdKey
+precName = varQual FSLIT("recPat") precIdKey
+varName = varQual FSLIT("varExp") varIdKey
+conName = varQual FSLIT("conExp") conIdKey
+litName = varQual FSLIT("litExp") litIdKey
+appName = varQual FSLIT("appExp") appIdKey
+infixEName = varQual FSLIT("infixExp") infixEIdKey
+lamName = varQual FSLIT("lamExp") lamIdKey
+tupName = varQual FSLIT("tupExp") tupIdKey
+doEName = varQual FSLIT("doExp") doEIdKey
+compName = varQual FSLIT("compExp") compIdKey
listExpName = varQual FSLIT("listExp") listExpIdKey
sigExpName = varQual FSLIT("sigExp") sigExpIdKey
-condName = varQual FSLIT("cond") condIdKey
-letEName = varQual FSLIT("letE") letEIdKey
-caseEName = varQual FSLIT("caseE") caseEIdKey
+condName = varQual FSLIT("condExp") condIdKey
+letEName = varQual FSLIT("letExp") letEIdKey
+caseEName = varQual FSLIT("caseExp") caseEIdKey
infixAppName = varQual FSLIT("infixApp") infixAppIdKey
sectionLName = varQual FSLIT("sectionL") sectionLIdKey
sectionRName = varQual FSLIT("sectionR") sectionRIdKey
-recConName = varQual FSLIT("recCon") recConIdKey
-recUpdName = varQual FSLIT("recUpd") recUpdIdKey
-guardedName = varQual FSLIT("guarded") guardedIdKey
-normalName = varQual FSLIT("normal") normalIdKey
-bindStName = varQual FSLIT("bindSt") bindStIdKey
-letStName = varQual FSLIT("letSt") letStIdKey
-noBindStName = varQual FSLIT("noBindSt") noBindStIdKey
-parStName = varQual FSLIT("parSt") parStIdKey
-fromName = varQual FSLIT("from") fromIdKey
-fromThenName = varQual FSLIT("fromThen") fromThenIdKey
-fromToName = varQual FSLIT("fromTo") fromToIdKey
-fromThenToName = varQual FSLIT("fromThenTo") fromThenToIdKey
+recConName = varQual FSLIT("recConExp") recConIdKey
+recUpdName = varQual FSLIT("recUpdExp") recUpdIdKey
+guardedName = varQual FSLIT("guardedRHS") guardedIdKey
+normalName = varQual FSLIT("normalRHS") normalIdKey
+bindStName = varQual FSLIT("bindStmt") bindStIdKey
+letStName = varQual FSLIT("letStmt") letStIdKey
+noBindStName = varQual FSLIT("noBindStmt") noBindStIdKey
+parStName = varQual FSLIT("parStmt") parStIdKey
+fromName = varQual FSLIT("fromExp") fromIdKey
+fromThenName = varQual FSLIT("fromThenExp") fromThenIdKey
+fromToName = varQual FSLIT("fromToExp") fromToIdKey
+fromThenToName = varQual FSLIT("fromThenToExp") fromThenToIdKey
liftName = varQual FSLIT("lift") liftIdKey
gensymName = varQual FSLIT("gensym") gensymIdKey
returnQName = varQual FSLIT("returnQ") returnQIdKey
clauseName = varQual FSLIT("clause") clauseIdKey
-- data Dec = ...
-funName = varQual FSLIT("fun") funIdKey
-valName = varQual FSLIT("val") valIdKey
-dataDName = varQual FSLIT("dataD") dataDIdKey
-newtypeDName = varQual FSLIT("newtypeD") newtypeDIdKey
-tySynDName = varQual FSLIT("tySynD") tySynDIdKey
-classDName = varQual FSLIT("classD") classDIdKey
-instName = varQual FSLIT("inst") instIdKey
-protoName = varQual FSLIT("proto") protoIdKey
+funName = varQual FSLIT("funDec") funIdKey
+valName = varQual FSLIT("valDec") valIdKey
+dataDName = varQual FSLIT("dataDec") dataDIdKey
+newtypeDName = varQual FSLIT("newtypeDec") newtypeDIdKey
+tySynDName = varQual FSLIT("tySynDec") tySynDIdKey
+classDName = varQual FSLIT("classDec") classDIdKey
+instName = varQual FSLIT("instanceDec") instIdKey
+protoName = varQual FSLIT("sigDec") protoIdKey
-- data Typ = ...
-tforallName = varQual FSLIT("tforall") tforallIdKey
-tvarName = varQual FSLIT("tvar") tvarIdKey
-tconName = varQual FSLIT("tcon") tconIdKey
-tappName = varQual FSLIT("tapp") tappIdKey
+tforallName = varQual FSLIT("forallTyp") tforallIdKey
+tvarName = varQual FSLIT("varTyp") tvarIdKey
+tconName = varQual FSLIT("conTyp") tconIdKey
+tappName = varQual FSLIT("appTyp") tappIdKey
-- data Tag = ...
arrowTyConName = varQual FSLIT("arrowTyCon") arrowIdKey
ctxtName = varQual FSLIT("cxt") ctxtIdKey
-- data Con = ...
-constrName = varQual FSLIT("constr") constrIdKey
-recConstrName = varQual FSLIT("recConstr") recConstrIdKey
-infixConstrName = varQual FSLIT("infixConstr") infixConstrIdKey
+constrName = varQual FSLIT("normalCon") constrIdKey
+recConstrName = varQual FSLIT("recCon") recConstrIdKey
+infixConstrName = varQual FSLIT("infixCon") infixConstrIdKey
exprTyConName = tcQual FSLIT("ExpQ") exprTyConKey
declTyConName = tcQual FSLIT("DecQ") declTyConKey
pattTyConName = tcQual FSLIT("Pat") pattTyConKey
mtchTyConName = tcQual FSLIT("MatchQ") mtchTyConKey
clseTyConName = tcQual FSLIT("ClauseQ") clseTyConKey
-stmtTyConName = tcQual FSLIT("StatementQ") stmtTyConKey
+stmtTyConName = tcQual FSLIT("StmtQ") stmtTyConKey
consTyConName = tcQual FSLIT("ConQ") consTyConKey
typeTyConName = tcQual FSLIT("TypQ") typeTyConKey
-strTypeTyConName = tcQual FSLIT("StrType") strTypeTyConKey
-varStrTypeTyConName = tcQual FSLIT("VarStrType") varStrTypeTyConKey
+strTypeTyConName = tcQual FSLIT("StrictTypQ") strTypeTyConKey
+varStrTypeTyConName = tcQual FSLIT("VarStrictTypQ") varStrTypeTyConKey
fieldTyConName = tcQual FSLIT("FieldExp") fieldTyConKey
fieldPTyConName = tcQual FSLIT("FieldPat") fieldPTyConKey
matTyConName = tcQual FSLIT("Match") matTyConKey
clsTyConName = tcQual FSLIT("Clause") clsTyConKey
-strictTypeName = varQual FSLIT("strictType") strictTypeKey
-varStrictTypeName = varQual FSLIT("varStrictType") varStrictTypeKey
-strictName = varQual FSLIT("strict") strictKey
-nonstrictName = varQual FSLIT("nonstrict") nonstrictKey
+strictTypeName = varQual FSLIT("strictTypQ") strictTypeKey
+varStrictTypeName = varQual FSLIT("varStrictTypQ") varStrictTypeKey
+strictName = varQual FSLIT("isStrict") strictKey
+nonstrictName = varQual FSLIT("notStrict") nonstrictKey
fieldName = varQual FSLIT("fieldExp") fieldKey
fieldPName = varQual FSLIT("fieldPat") fieldPKey
convertToHsDecls ds = map cvt_top ds
mk_con con = case con of
- Constr c strtys
+ NormalCon c strtys
-> ConDecl (cName c) noExistentials noContext
(PrefixCon (map mk_arg strtys)) loc0
- RecConstr c varstrtys
+ Meta.RecCon c varstrtys
-> ConDecl (cName c) noExistentials noContext
(Hs.RecCon (map mk_id_arg varstrtys)) loc0
- InfixConstr st1 c st2
+ Meta.InfixCon st1 c st2
-> ConDecl (cName c) noExistentials noContext
- (InfixCon (mk_arg st1) (mk_arg st2)) loc0
+ (Hs.InfixCon (mk_arg st1) (mk_arg st2)) loc0
where
- mk_arg (Strict, ty) = BangType MarkedUserStrict (cvtType ty)
- mk_arg (NonStrict, ty) = BangType NotMarkedStrict (cvtType ty)
+ mk_arg (IsStrict, ty) = BangType MarkedUserStrict (cvtType ty)
+ mk_arg (NotStrict, ty) = BangType NotMarkedStrict (cvtType ty)
- mk_id_arg (i, Strict, ty)
+ mk_id_arg (i, IsStrict, ty)
= (vName i, BangType MarkedUserStrict (cvtType ty))
- mk_id_arg (i, NonStrict, ty)
+ mk_id_arg (i, NotStrict, ty)
= (vName i, BangType NotMarkedStrict (cvtType ty))
mk_derivs [] = Nothing
mk_derivs cs = Just [HsClassP (tconName c) [] | c <- cs]
cvt_top :: Meta.Dec -> Either (HsDecl RdrName) Message
-cvt_top d@(Val _ _ _) = Left $ ValD (cvtd d)
-cvt_top d@(Fun _ _) = Left $ ValD (cvtd d)
+cvt_top d@(ValDec _ _ _) = Left $ ValD (cvtd d)
+cvt_top d@(FunDec _ _) = Left $ ValD (cvtd d)
-cvt_top (TySyn tc tvs rhs)
+cvt_top (TySynDec tc tvs rhs)
= Left $ TyClD (TySynonym (tconName tc) (cvt_tvs tvs) (cvtType rhs) loc0)
-cvt_top (Data ctxt tc tvs constrs derivs)
+cvt_top (DataDec ctxt tc tvs constrs derivs)
= Left $ TyClD (mkTyData DataType
(cvt_context ctxt, tconName tc, cvt_tvs tvs)
(DataCons (map mk_con constrs))
(mk_derivs derivs) loc0)
-cvt_top (Newtype ctxt tc tvs constr derivs)
+cvt_top (NewtypeDec ctxt tc tvs constr derivs)
= Left $ TyClD (mkTyData NewType
(cvt_context ctxt, tconName tc, cvt_tvs tvs)
(DataCons [mk_con constr])
(mk_derivs derivs) loc0)
-cvt_top (Class ctxt cl tvs decs)
+cvt_top (ClassDec ctxt cl tvs decs)
= Left $ TyClD (mkClassDecl (cvt_context ctxt, tconName cl, cvt_tvs tvs)
noFunDeps sigs
(Just binds) loc0)
where
(binds,sigs) = cvtBindsAndSigs decs
-cvt_top (Instance tys ty decs)
+cvt_top (InstanceDec tys ty decs)
= Left $ InstD (InstDecl inst_ty binds sigs Nothing loc0)
where
(binds, sigs) = cvtBindsAndSigs decs
(cvt_context tys)
(HsPredTy (cvt_pred ty))
-cvt_top (Proto nm typ) = Left $ SigD (Sig (vName nm) (cvtType typ) loc0)
+cvt_top (SigDec nm typ) = Left $ SigD (Sig (vName nm) (cvtType typ) loc0)
-cvt_top (Foreign (Import callconv safety from nm typ))
+cvt_top (ForeignDec (ImportForeign callconv safety from nm typ))
= case parsed of
Just (c_header, cis) ->
let i = CImport callconv' safety' c_header nilFS cis
convertToHsExpr :: Meta.Exp -> HsExpr RdrName
convertToHsExpr = cvt
-cvt (Var s) = HsVar (vName s)
-cvt (Con s) = HsVar (cName s)
-cvt (Lit l)
+cvt (VarExp s) = HsVar (vName s)
+cvt (ConExp s) = HsVar (cName s)
+cvt (LitExp l)
| overloadedLit l = HsOverLit (cvtOverLit l)
| otherwise = HsLit (cvtLit l)
-cvt (App x y) = HsApp (cvt x) (cvt y)
-cvt (Lam ps e) = HsLam (mkSimpleMatch (map cvtp ps) (cvt e) void loc0)
-cvt (Tup [e]) = cvt e
-cvt (Tup es) = ExplicitTuple(map cvt es) Boxed
-cvt (Cond x y z) = HsIf (cvt x) (cvt y) (cvt z) loc0
-cvt (Let ds e) = HsLet (cvtdecs ds) (cvt e)
-cvt (Case e ms) = HsCase (cvt e) (map cvtm ms) loc0
-cvt (Do ss) = HsDo DoExpr (cvtstmts ss) [] void loc0
-cvt (Comp ss) = HsDo ListComp (cvtstmts ss) [] void loc0
-cvt (ArithSeq dd) = ArithSeqIn (cvtdd dd)
+cvt (AppExp x y) = HsApp (cvt x) (cvt y)
+cvt (LamExp ps e) = HsLam (mkSimpleMatch (map cvtp ps) (cvt e) void loc0)
+cvt (TupExp [e]) = cvt e
+cvt (TupExp es) = ExplicitTuple(map cvt es) Boxed
+cvt (CondExp x y z) = HsIf (cvt x) (cvt y) (cvt z) loc0
+cvt (LetExp ds e) = HsLet (cvtdecs ds) (cvt e)
+cvt (CaseExp e ms) = HsCase (cvt e) (map cvtm ms) loc0
+cvt (DoExp ss) = HsDo DoExpr (cvtstmts ss) [] void loc0
+cvt (CompExp ss) = HsDo ListComp (cvtstmts ss) [] void loc0
+cvt (ArithSeqExp dd) = ArithSeqIn (cvtdd dd)
cvt (ListExp xs) = ExplicitList void (map cvt xs)
-cvt (Infix (Just x) s (Just y))
+cvt (InfixExp (Just x) s (Just y))
= HsPar (OpApp (cvt x) (cvt s) undefined (cvt y))
-cvt (Infix Nothing s (Just y)) = SectionR (cvt s) (cvt y)
-cvt (Infix (Just x) s Nothing ) = SectionL (cvt x) (cvt s)
-cvt (Infix Nothing s Nothing ) = cvt s -- Can I indicate this is an infix thing?
+cvt (InfixExp Nothing s (Just y)) = SectionR (cvt s) (cvt y)
+cvt (InfixExp (Just x) s Nothing ) = SectionL (cvt x) (cvt s)
+cvt (InfixExp Nothing s Nothing ) = cvt s -- Can I indicate this is an infix thing?
cvt (SigExp e t) = ExprWithTySig (cvt e) (cvtType t)
-cvt (Meta.RecCon c flds) = RecordCon (cName c) (map (\(x,y) -> (vName x, cvt y)) flds)
-cvt (RecUpd e flds) = RecordUpd (cvt e) (map (\(x,y) -> (vName x, cvt y)) flds)
+cvt (RecConExp c flds) = RecordCon (cName c) (map (\(x,y) -> (vName x, cvt y)) flds)
+cvt (RecUpdExp e flds) = RecordUpd (cvt e) (map (\(x,y) -> (vName x, cvt y)) flds)
cvtdecs :: [Meta.Dec] -> HsBinds RdrName
cvtdecs [] = EmptyBinds
where
(sigs, non_sigs) = partition sigP ds
-cvtSig (Proto nm typ) = Sig (vName nm) (cvtType typ) loc0
+cvtSig (SigDec nm typ) = Sig (vName nm) (cvtType typ) loc0
cvtds :: [Meta.Dec] -> MonoBinds RdrName
cvtds [] = EmptyMonoBinds
cvtd :: Meta.Dec -> MonoBinds RdrName
-- Used only for declarations in a 'let/where' clause,
-- not for top level decls
-cvtd (Val (Pvar s) body ds) = FunMonoBind (vName s) False
+cvtd (ValDec (Meta.VarPat s) body ds) = FunMonoBind (vName s) False
[cvtclause (Clause [] body ds)] loc0
-cvtd (Fun nm cls) = FunMonoBind (vName nm) False (map cvtclause cls) loc0
-cvtd (Val p body ds) = PatMonoBind (cvtp p) (GRHSs (cvtguard body)
+cvtd (FunDec nm cls) = FunMonoBind (vName nm) False (map cvtclause cls) loc0
+cvtd (ValDec p body ds) = PatMonoBind (cvtp p) (GRHSs (cvtguard body)
(cvtdecs ds)
void) loc0
cvtd x = panic "Illegal kind of declaration in where clause"
cvtdd :: Meta.DotDot -> ArithSeqInfo RdrName
-cvtdd (Meta.From x) = (Hs.From (cvt x))
-cvtdd (Meta.FromThen x y) = (Hs.FromThen (cvt x) (cvt y))
-cvtdd (Meta.FromTo x y) = (Hs.FromTo (cvt x) (cvt y))
-cvtdd (Meta.FromThenTo x y z) = (Hs.FromThenTo (cvt x) (cvt y) (cvt z))
+cvtdd (FromDotDot x) = (Hs.From (cvt x))
+cvtdd (FromThenDotDot x y) = (Hs.FromThen (cvt x) (cvt y))
+cvtdd (FromToDotDot x y) = (Hs.FromTo (cvt x) (cvt y))
+cvtdd (FromThenToDotDot x y z) = (Hs.FromThenTo (cvt x) (cvt y) (cvt z))
-cvtstmts :: [Meta.Statement] -> [Hs.Stmt RdrName]
+cvtstmts :: [Meta.Stmt] -> [Hs.Stmt RdrName]
cvtstmts [] = [] -- this is probably an error as every [stmt] should end with ResultStmt
-cvtstmts [NoBindSt e] = [ResultStmt (cvt e) loc0] -- when its the last element use ResultStmt
-cvtstmts (NoBindSt e : ss) = ExprStmt (cvt e) void loc0 : cvtstmts ss
-cvtstmts (BindSt p e : ss) = BindStmt (cvtp p) (cvt e) loc0 : cvtstmts ss
-cvtstmts (LetSt ds : ss) = LetStmt (cvtdecs ds) : cvtstmts ss
-cvtstmts (ParSt dss : ss) = ParStmt(map cvtstmts dss) : cvtstmts ss
+cvtstmts [NoBindStmt e] = [ResultStmt (cvt e) loc0] -- when its the last element use ResultStmt
+cvtstmts (NoBindStmt e : ss) = ExprStmt (cvt e) void loc0 : cvtstmts ss
+cvtstmts (Meta.BindStmt p e : ss) = Hs.BindStmt (cvtp p) (cvt e) loc0 : cvtstmts ss
+cvtstmts (Meta.LetStmt ds : ss) = Hs.LetStmt (cvtdecs ds) : cvtstmts ss
+cvtstmts (Meta.ParStmt dss : ss) = Hs.ParStmt(map cvtstmts dss) : cvtstmts ss
cvtm :: Meta.Match -> Hs.Match RdrName
cvtm (Meta.Match p body wheres)
= Hs.Match [cvtp p] Nothing (GRHSs (cvtguard body) (cvtdecs wheres) void)
-cvtguard :: Meta.RightHandSide -> [GRHS RdrName]
-cvtguard (Guarded pairs) = map cvtpair pairs
-cvtguard (Normal e) = [GRHS [ ResultStmt (cvt e) loc0 ] loc0]
+cvtguard :: Meta.RHS -> [GRHS RdrName]
+cvtguard (GuardedRHS pairs) = map cvtpair pairs
+cvtguard (NormalRHS e) = [GRHS [ ResultStmt (cvt e) loc0 ] loc0]
cvtpair :: (Meta.Exp,Meta.Exp) -> GRHS RdrName
-cvtpair (x,y) = GRHS [BindStmt truePat (cvt x) loc0,
+cvtpair (x,y) = GRHS [Hs.BindStmt truePat (cvt x) loc0,
ResultStmt (cvt y) loc0] loc0
cvtOverLit :: Lit -> HsOverLit
-cvtOverLit (Integer i) = mkHsIntegral i
-cvtOverLit (Rational r) = mkHsFractional r
+cvtOverLit (IntegerLit i) = mkHsIntegral i
+cvtOverLit (RationalLit r) = mkHsFractional r
-- An Integer is like an an (overloaded) '3' in a Haskell source program
-- Similarly 3.5 for fractionals
cvtLit :: Lit -> HsLit
-cvtLit (IntPrim i) = HsIntPrim i
-cvtLit (FloatPrim f) = HsFloatPrim f
-cvtLit (DoublePrim f) = HsDoublePrim f
-cvtLit (Char c) = HsChar (ord c)
-cvtLit (String s) = HsString (mkFastString s)
+cvtLit (IntPrimLit i) = HsIntPrim i
+cvtLit (FloatPrimLit f) = HsFloatPrim f
+cvtLit (DoublePrimLit f) = HsDoublePrim f
+cvtLit (CharLit c) = HsChar (ord c)
+cvtLit (StringLit s) = HsString (mkFastString s)
cvtp :: Meta.Pat -> Hs.Pat RdrName
-cvtp (Plit l)
+cvtp (Meta.LitPat l)
| overloadedLit l = NPatIn (cvtOverLit l) Nothing -- Not right for negative
-- patterns; need to think
-- about that!
- | otherwise = LitPat (cvtLit l)
-cvtp (Pvar s) = VarPat(vName s)
-cvtp (Ptup [p]) = cvtp p
-cvtp (Ptup ps) = TuplePat (map cvtp ps) Boxed
-cvtp (Pcon s ps) = ConPatIn (cName s) (PrefixCon (map cvtp ps))
-cvtp (Ptilde p) = LazyPat (cvtp p)
-cvtp (Paspat s p) = AsPat (vName s) (cvtp p)
-cvtp Pwild = WildPat void
-cvtp (Prec c fs) = ConPatIn (cName c) $ Hs.RecCon (map (\(s,p) -> (vName s,cvtp p)) fs)
+ | otherwise = Hs.LitPat (cvtLit l)
+cvtp (Meta.VarPat s) = Hs.VarPat(vName s)
+cvtp (TupPat [p]) = cvtp p
+cvtp (TupPat ps) = TuplePat (map cvtp ps) Boxed
+cvtp (ConPat s ps) = ConPatIn (cName s) (PrefixCon (map cvtp ps))
+cvtp (TildePat p) = LazyPat (cvtp p)
+cvtp (Meta.AsPat s p) = Hs.AsPat (vName s) (cvtp p)
+cvtp Meta.WildPat = Hs.WildPat void
+cvtp (RecPat c fs) = ConPatIn (cName c) $ Hs.RecCon (map (\(s,p) -> (vName s,cvtp p)) fs)
-----------------------------------------------------------
-- Types and type variables
cvt_pred :: Typ -> HsPred RdrName
cvt_pred ty = case split_ty_app ty of
- (Tcon (TconName tc), tys) -> HsClassP (tconName tc) (map cvtType tys)
+ (ConTyp (ConNameTag tc), tys) -> HsClassP (tconName tc) (map cvtType tys)
other -> panic "Malformed predicate"
cvtType :: Meta.Typ -> HsType RdrName
cvtType ty = trans (root ty [])
- where root (Tapp a b) zs = root a (cvtType b : zs)
+ where root (AppTyp a b) zs = root a (cvtType b : zs)
root t zs = (t,zs)
- trans (Tcon (Tuple n),args) | length args == n
+ trans (ConTyp (TupleTag n),args) | length args == n
= HsTupleTy (HsTupCon Boxed n) args
- trans (Tcon Arrow, [x,y]) = HsFunTy x y
- trans (Tcon List, [x]) = HsListTy x
+ trans (ConTyp ArrowTag, [x,y]) = HsFunTy x y
+ trans (ConTyp ListTag, [x]) = HsListTy x
- trans (Tvar nm, args) = foldl HsAppTy (HsTyVar (tName nm)) args
- trans (Tcon tc, args) = foldl HsAppTy (HsTyVar (tc_name tc)) args
+ trans (VarTyp nm, args) = foldl HsAppTy (HsTyVar (tName nm)) args
+ trans (ConTyp tc, args) = foldl HsAppTy (HsTyVar (tc_name tc)) args
- trans (TForall tvs cxt ty, []) = mkHsForAllTy (Just (cvt_tvs tvs))
+ trans (ForallTyp tvs cxt ty, []) = mkHsForAllTy (Just (cvt_tvs tvs))
(cvt_context cxt)
(cvtType ty)
- tc_name (TconName nm) = tconName nm
- tc_name Arrow = tconName "->"
- tc_name List = tconName "[]"
- tc_name (Tuple 0) = tconName "()"
- tc_name (Tuple n) = tconName ("(" ++ replicate (n-1) ',' ++ ")")
+ tc_name (ConNameTag nm) = tconName nm
+ tc_name ArrowTag = tconName "->"
+ tc_name ListTag = tconName "[]"
+ tc_name (TupleTag 0) = tconName "()"
+ tc_name (TupleTag n) = tconName ("(" ++ replicate (n-1) ',' ++ ")")
split_ty_app :: Typ -> (Typ, [Typ])
split_ty_app ty = go ty []
where
- go (Tapp f a) as = go f (a:as)
+ go (AppTyp f a) as = go f (a:as)
go f as = (f,as)
-----------------------------------------------------------
sigP :: Dec -> Bool
-sigP (Proto _ _) = True
+sigP (SigDec _ _) = True
sigP other = False
overloadedLit :: Lit -> Bool
-- True for literals that Haskell treats as overloaded
-overloadedLit (Integer l) = True
-overloadedLit (Rational l) = True
-overloadedLit l = False
+overloadedLit (IntegerLit l) = True
+overloadedLit (RationalLit l) = True
+overloadedLit l = False
void :: Type.Type
void = placeHolderType
is_sep ':' = True
is_sep other = False
\end{code}
+