diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-08-29 12:38:54 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-08-29 12:39:18 -0400 |
commit | 895a7650a038131f3043f882c558c627abe9a61e (patch) | |
tree | 69a1948f4303d5801ac21884c68a61556e285268 /compiler/rename/RnNames.hs | |
parent | 5266ab9059dffa741b172636f50f1fbfd491dbb4 (diff) | |
download | haskell-895a7650a038131f3043f882c558c627abe9a61e.tar.gz |
Refactor type family instance abstract syntax declarations
This implements @simonpj's suggested refactoring of the abstract syntax
for type/data family instances (from
https://ghc.haskell.org/trac/ghc/ticket/14131#comment:9). This combines
the previously separate `TyFamEqn` and `DataFamInstDecl` types into a
single `FamEqn` datatype. This also factors the `HsImplicitBndrs` out of
`HsTyPats` in favor of putting them just outside of `FamEqn` (as opposed
to before, where all of the implicit binders were embedded inside of
`TyFamEqn`/`DataFamInstDecl`). Finally, along the way I noticed that
`dfid_fvs` and `tfid_fvs` were completely unused, so I removed them.
Aside from some changes in parser test output, there is no change in
behavior.
Requires a Haddock submodule commit from my fork (at
https://github.com/RyanGlScott/haddock/commit/815d2deb9c0222c916becccf84
64b740c26255fd)
Test Plan: ./validate
Reviewers: simonpj, austin, goldfire, bgamari, alanz
Reviewed By: bgamari
Subscribers: mpickering, goldfire, rwbarton, thomie, simonpj
GHC Trac Issues: #14131
Differential Revision: https://phabricator.haskell.org/D3881
Diffstat (limited to 'compiler/rename/RnNames.hs')
-rw-r--r-- | compiler/rename/RnNames.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs index 6197bc7480..84e62f0113 100644 --- a/compiler/rename/RnNames.hs +++ b/compiler/rename/RnNames.hs @@ -688,14 +688,15 @@ getLocalNonValBinders fixity_env new_di :: Bool -> Maybe Name -> DataFamInstDecl GhcPs -> RnM (AvailInfo, [(Name, [FieldLabel])]) - new_di overload_ok mb_cls ti_decl - = do { main_name <- lookupFamInstName mb_cls (dfid_tycon ti_decl) - ; let (bndrs, flds) = hsDataFamInstBinders ti_decl + new_di overload_ok mb_cls dfid@(DataFamInstDecl { dfid_eqn = + HsIB { hsib_body = ti_decl }}) + = do { main_name <- lookupFamInstName mb_cls (feqn_tycon ti_decl) + ; let (bndrs, flds) = hsDataFamInstBinders dfid ; sub_names <- mapM newTopSrcBinder bndrs ; flds' <- mapM (newRecordSelector overload_ok sub_names) flds ; let avail = AvailTC (unLoc main_name) sub_names flds' -- main_name is not bound here! - fld_env = mk_fld_env (dfid_defn ti_decl) sub_names flds' + fld_env = mk_fld_env (feqn_rhs ti_decl) sub_names flds' ; return (avail, fld_env) } new_loc_di :: Bool -> Maybe Name -> LDataFamInstDecl GhcPs |