import HsSyn as Hs
( HsExpr(..), HsLit(..), ArithSeqInfo(..),
- HsStmtContext(..), TyClDecl(..),
+ HsStmtContext(..), TyClDecl(..), HsBang(..),
Match(..), GRHSs(..), GRHS(..), HsPred(..),
HsDecl(..), TyClDecl(..), InstDecl(..), ConDecl(..),
Stmt(..), HsBinds(..), MonoBinds(..), Sig(..),
Pat(..), HsConDetails(..), HsOverLit, BangType(..),
- placeHolderType, HsType(..), HsTupCon(..),
+ placeHolderType, HsType(..), HsExplicitForAll(..),
HsTyVarBndr(..), HsContext,
- mkSimpleMatch, mkHsForAllTy
+ mkSimpleMatch, mkImplicitHsForAllTy, mkExplicitHsForAllTy
)
import RdrName ( RdrName, mkRdrUnqual, mkRdrQual, mkOrig )
import RdrHsSyn ( mkHsIntegral, mkHsFractional, mkClassDecl, mkTyData )
import OccName
import SrcLoc ( SrcLoc, generatedSrcLoc )
-import TyCon ( DataConDetails(..) )
import Type ( Type )
-import BasicTypes( Boxity(..), RecFlag(Recursive),
- NewOrData(..), StrictnessMark(..) )
+import BasicTypes( Boxity(..), RecFlag(Recursive), NewOrData(..) )
import ForeignCall ( Safety(..), CCallConv(..), CCallTarget(..),
CExportSpec(..))
import HsDecls ( CImportSpec(..), ForeignImport(..), ForeignExport(..),
-> ConDecl (cName c) noExistentials noContext
(InfixCon (mk_arg st1) (mk_arg st2)) loc0
where
- mk_arg (IsStrict, ty) = BangType MarkedUserStrict (cvtType ty)
- mk_arg (NotStrict, ty) = BangType NotMarkedStrict (cvtType ty)
+ mk_arg (IsStrict, ty) = BangType HsStrict (cvtType ty)
+ mk_arg (NotStrict, ty) = BangType HsNoBang (cvtType ty)
mk_id_arg (i, IsStrict, ty)
- = (vName i, BangType MarkedUserStrict (cvtType ty))
+ = (vName i, BangType HsStrict (cvtType ty))
mk_id_arg (i, NotStrict, ty)
- = (vName i, BangType NotMarkedStrict (cvtType ty))
+ = (vName i, BangType HsNoBang (cvtType ty))
mk_derivs [] = Nothing
mk_derivs cs = Just [HsClassP (tconName c) [] | c <- cs]
cvt_top (DataD ctxt tc tvs constrs derivs)
= Left $ TyClD (mkTyData DataType
(cvt_context ctxt, tconName tc, cvt_tvs tvs)
- (DataCons (map mk_con constrs))
+ (map mk_con constrs)
(mk_derivs derivs) loc0)
cvt_top (NewtypeD ctxt tc tvs constr derivs)
= Left $ TyClD (mkTyData NewType
(cvt_context ctxt, tconName tc, cvt_tvs tvs)
- (DataCons [mk_con constr])
+ [mk_con constr]
(mk_derivs derivs) loc0)
cvt_top (ClassD ctxt cl tvs decs)
= Left $ TyClD (mkClassDecl (cvt_context ctxt, tconName cl, cvt_tvs tvs)
noFunDeps sigs
- (Just binds) loc0)
+ binds loc0)
where
(binds,sigs) = cvtBindsAndSigs decs
cvt_top (InstanceD tys ty decs)
- = Left $ InstD (InstDecl inst_ty binds sigs Nothing loc0)
+ = Left $ InstD (InstDecl inst_ty binds sigs loc0)
where
(binds, sigs) = cvtBindsAndSigs decs
- inst_ty = HsForAllTy Nothing
- (cvt_context tys)
- (HsPredTy (cvt_pred ty))
+ inst_ty = mkImplicitHsForAllTy (cvt_context tys) (HsPredTy (cvt_pred ty))
cvt_top (Meta.SigD nm typ) = Left $ Hs.SigD (Sig (vName nm) (cvtType typ) loc0)
cvt_pred :: Meta.Type -> HsPred RdrName
cvt_pred ty = case split_ty_app ty of
(ConT tc, tys) -> HsClassP (tconName tc) (map cvtType tys)
- other -> panic "Malformed predicate"
+ other -> pprPanic "Malformed predicate" (text (show (Meta.pprType ty)))
cvtType :: Meta.Type -> HsType RdrName
cvtType ty = trans (root ty [])
root t zs = (t,zs)
trans (TupleT n,args)
- | length args == n = HsTupleTy (HsTupCon Boxed n) args
+ | length args == n = HsTupleTy Boxed args
| n == 0 = foldl HsAppTy (HsTyVar (tconName "()")) args
| otherwise = foldl HsAppTy (HsTyVar (tconName ("(" ++ replicate (n-1) ',' ++ ")"))) args
trans (ArrowT, [x,y]) = HsFunTy x y
trans (VarT nm, args) = foldl HsAppTy (HsTyVar (tName nm)) args
trans (ConT tc, args) = foldl HsAppTy (HsTyVar (tconName tc)) args
- trans (ForallT tvs cxt ty, []) = mkHsForAllTy (Just (cvt_tvs tvs))
- (cvt_context cxt)
- (cvtType ty)
+ trans (ForallT tvs cxt ty, []) = mkExplicitHsForAllTy
+ (cvt_tvs tvs) (cvt_context cxt) (cvtType ty)
split_ty_app :: Meta.Type -> (Meta.Type, [Meta.Type])
split_ty_app ty = go ty []