diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-04-20 18:38:25 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-04-20 18:38:25 +0100 |
commit | c284511ca063a1a80e1f5479364c5cfd2e7217f8 (patch) | |
tree | bf6bc34871ab0a7156f65030c98140577c7b3b56 /compiler/hsSyn | |
parent | c163e38a581694a3518720500fcc5a1dd5336f0c (diff) | |
download | haskell-c284511ca063a1a80e1f5479364c5cfd2e7217f8.tar.gz |
Move free-var info from InstDecl to FamInstDecl
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r-- | compiler/hsSyn/Convert.lhs | 36 | ||||
-rw-r--r-- | compiler/hsSyn/HsDecls.lhs | 8 |
2 files changed, 23 insertions, 21 deletions
diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs index 5c847c89e9..2ee7692052 100644 --- a/compiler/hsSyn/Convert.lhs +++ b/compiler/hsSyn/Convert.lhs @@ -164,8 +164,8 @@ cvtDec (TySynD tc tvs rhs) = do { (_, tc', tvs') <- cvt_tycl_hdr [] tc tvs ; rhs' <- cvtType rhs ; returnL $ TyClD (TyDecl { tcdLName = tc' - , tcdTyVars = tvs' - , tcdTyDefn = TySynonym rhs' placeHolderNames }) } + , tcdTyVars = tvs', tcdFVs = placeHolderNames + , tcdTyDefn = TySynonym rhs' }) } cvtDec (DataD ctxt tc tvs constrs derivs) = do { (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs @@ -174,10 +174,9 @@ cvtDec (DataD ctxt tc tvs constrs derivs) ; let defn = TyData { td_ND = DataType, td_cType = Nothing , td_ctxt = ctxt' , td_kindSig = Nothing - , td_cons = cons', td_derivs = derivs' - , td_fvs = placeHolderNames } + , td_cons = cons', td_derivs = derivs' } ; returnL $ TyClD (TyDecl { tcdLName = tc', tcdTyVars = tvs' - , tcdTyDefn = defn }) } + , tcdTyDefn = defn, tcdFVs = placeHolderNames }) } cvtDec (NewtypeD ctxt tc tvs constr derivs) = do { (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs @@ -186,10 +185,9 @@ cvtDec (NewtypeD ctxt tc tvs constr derivs) ; let defn = TyData { td_ND = NewType, td_cType = Nothing , td_ctxt = ctxt' , td_kindSig = Nothing - , td_cons = [con'], td_derivs = derivs' - , td_fvs = placeHolderNames } + , td_cons = [con'], td_derivs = derivs' } ; returnL $ TyClD (TyDecl { tcdLName = tc', tcdTyVars = tvs' - , tcdTyDefn = defn }) } + , tcdTyDefn = defn, tcdFVs = placeHolderNames }) } cvtDec (ClassD ctxt cl tvs fds decs) = do { (cxt', tc', tvs') <- cvt_tycl_hdr ctxt cl tvs @@ -198,7 +196,8 @@ cvtDec (ClassD ctxt cl tvs fds decs) ; returnL $ TyClD $ ClassDecl { tcdCtxt = cxt', tcdLName = tc', tcdTyVars = tvs' , tcdFDs = fds', tcdSigs = sigs', tcdMeths = binds' - , tcdATs = fams', tcdATDefs = ats', tcdDocs = [] } + , tcdATs = fams', tcdATDefs = ats', tcdDocs = [] + , tcdFVs = placeHolderNames } -- no docs in TH ^^ } @@ -232,8 +231,9 @@ cvtDec (DataInstD ctxt tc tys constrs derivs) , td_kindSig = Nothing , td_cons = cons', td_derivs = derivs' } - ; returnL $ InstD $ FamInstD $ - FamInstDecl { fid_tycon = tc', fid_pats = typats', fid_defn = defn } } + ; returnL $ InstD $ FamInstD + { lid_inst = FamInstDecl { fid_tycon = tc', fid_pats = typats' + , fid_defn = defn, fid_fvs = placeHolderNames } }} cvtDec (NewtypeInstD ctxt tc tys constr derivs) = do { (ctxt', tc', typats') <- cvt_tyinst_hdr ctxt tc tys @@ -243,14 +243,16 @@ cvtDec (NewtypeInstD ctxt tc tys constr derivs) , td_ctxt = ctxt' , td_kindSig = Nothing , td_cons = [con'], td_derivs = derivs' } - ; returnL $ InstD $ FamInstD $ - FamInstDecl { fid_tycon = tc', fid_pats = typats', fid_defn = defn } } + ; returnL $ InstD $ FamInstD + { lid_inst = FamInstDecl { fid_tycon = tc', fid_pats = typats' + , fid_defn = defn, fid_fvs = placeHolderNames } } } cvtDec (TySynInstD tc tys rhs) = do { (_, tc', tys') <- cvt_tyinst_hdr [] tc tys ; rhs' <- cvtType rhs - ; returnL $ InstD $ FamInstD $ - FamInstDecl { fid_tycon = tc', fid_pats = tys', fid_defn = TySynonym rhs' } } + ; returnL $ InstD $ FamInstD + { lid_inst = FamInstDecl { fid_tycon = tc', fid_pats = tys' + , fid_defn = TySynonym rhs', fid_fvs = placeHolderNames } } } ---------------- cvt_ci_decs :: MsgDoc -> [TH.Dec] @@ -300,8 +302,8 @@ is_fam_decl (L loc (TyClD d@(TyFamily {}))) = Left (L loc d) is_fam_decl decl = Right decl is_fam_inst :: LHsDecl RdrName -> Either (LFamInstDecl RdrName) (LHsDecl RdrName) -is_fam_inst (L loc (Hs.InstD (FamInstD d))) = Left (L loc d) -is_fam_inst decl = Right decl +is_fam_inst (L loc (Hs.InstD (FamInstD { lid_inst = d }))) = Left (L loc d) +is_fam_inst decl = Right decl is_sig :: LHsDecl RdrName -> Either (LSig RdrName) (LHsDecl RdrName) is_sig (L loc (Hs.SigD sig)) = Left (L loc sig) diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs index e23006279f..c789a9efdc 100644 --- a/compiler/hsSyn/HsDecls.lhs +++ b/compiler/hsSyn/HsDecls.lhs @@ -809,7 +809,8 @@ data FamInstDecl name = FamInstDecl { fid_tycon :: Located name , fid_pats :: HsBndrSig [LHsType name] -- ^ Type patterns (with bndrs) - , fid_defn :: HsTyDefn name } -- Type or data family instance + , fid_defn :: HsTyDefn name -- Type or data family instance + , fid_fvs :: NameSet } deriving( Typeable, Data ) type LInstDecl name = Located (InstDecl name) @@ -821,11 +822,10 @@ data InstDecl name -- Both class and family instances , cid_binds :: LHsBinds name , cid_sigs :: [LSig name] -- User-supplied pragmatic info , cid_fam_insts :: [LFamInstDecl name] -- Family instances for associated types - , lid_fvs :: NameSet } + } | FamInstD -- type/data family instance - { lid_inst :: FamInstDecl name - , lid_fvs :: NameSet } + { lid_inst :: FamInstDecl name } deriving (Data, Typeable) \end{code} |