- all_binds = implicit_con_wrappers ++ other_implicit_binds ++ binds
- -- Put the constructor wrappers first, because
- -- other implicit bindings (notably the fromT functions arising
- -- from generics) use the constructor wrappers.
-
- tycons = map classTyCon (typeEnvClasses type_env) ++ typeEnvTyCons type_env
-
- implicit_con_wrappers = map get_defn (concatMap implicit_con_ids (typeEnvElts type_env))
- other_implicit_binds = map get_defn (concatMap other_implicit_ids (typeEnvElts type_env))
-
-implicit_con_ids :: TyThing -> [Id]
-implicit_con_ids (ATyCon tc) | isAlgTyCon tc = mapCatMaybes dataConWrapId_maybe (tyConDataCons tc)
-implicit_con_ids other = []
-
-other_implicit_ids :: TyThing -> [Id]
-other_implicit_ids (ATyCon tc) = tyConSelIds tc
-other_implicit_ids (AClass cl) = classSelIds cl
-other_implicit_ids other = []
-
-get_defn :: Id -> CoreBind
-get_defn id = NonRec id rhs
- where
- rhs = tidyExpr emptyTidyEnv body
- body = unfoldingTemplate (idUnfolding id)
- -- Don't forget to tidy the body ! Otherwise you get silly things like
- -- \ tpl -> case tpl of tpl -> (tpl,tpl) -> tpl
- -- Maybe we should inject these bindings during CoreTidy?
-