logo       

RE: Core, implicit bindings are emitted in the wrong order: msg#00012

lang.haskell.glasgow.bugs

Subject: RE: Core, implicit bindings are emitted in the wrong order

I've made this fix in the HEAD, thank you.

Simon

| -----Original Message-----
| From: Tobias Gedell [mailto:d99getob@xxxxxxxxxxxxxxxx]
| Sent: 25 January 2003 11:54
| To: glasgow-haskell-bugs
| Subject: Core, implicit bindings are emitted in the wrong order
|
| The implicit bindings are emitted in the wrong order when generating
Core.
|
| It seems like the problem occurs since the implicit bindings does not
| only consist of wrappers and class functions but also conversion
| functions. These conversion functions sometimes use wrappers that have
| not yet been defined.
|
| An example of this is found at line 240 in Base.hcr (generated with
the
| -O0 flag):
|
| -------------
| GHCziBase.zdgfromBool ::
| GHCziBase.Bool ->
| GHCziBase.ZCzpZC GHCziBase.Unit GHCziBase.Unit =
| \ (g::GHCziBase.Bool) ->
| %case g %of (g1::GHCziBase.Bool)
| {
| GHCziBase.False ->
| GHCziBase.Inl @ GHCziBase.Unit @ GHCziBase.Unit GHCziBase.Unit;
| GHCziBase.True ->
| GHCziBase.Inr @ GHCziBase.Unit @ GHCziBase.Unit GHCziBase.Unit
| };
| --------------
|
| Here we try to use the wrappers GHCziBase.Inl and GHCziBase.Inr but
they
| are defined first at line 346.
|
|
| Maybe these conversion functions only use GHCziBase.ZCzpZC and then a
| possible fix would be to make sure that GHCziBase.Inl and
GHCziBase.Inr
| are defined before all other implicit bindings.
|
| Another possible fix that I have implemented is to make sure that all
| wrappers are defined before all other implicit bindings.
|
|
| I have replaced line 53-70 in ghc/compiler/coreSyn/MkExternalCore.lhs
with:
|
| ----------
| mkExternalCore :: ModGuts -> C.Module
| mkExternalCore (ModGuts {mg_module=this_mod, mg_types = type_env,
| mg_binds = binds})
| = C.Module mname tdefs vdefs
| where
| mname = make_mid this_mod
| tdefs = foldr collect_tdefs [] tycons
| -- Don't forget to include the implicit bindings!
| vdefs = map make_vdef (implicit_wbinds ++ implicit_binds ++
binds)
| tycons = map classTyCon (typeEnvClasses type_env) ++
typeEnvTyCons
| type_env
|
| tything = typeEnvElts type_env
| implicit_wbinds = map get_defn $ concatMap implicit_wids tything
| implicit_binds = map get_defn $ concatMap implicit_ids tything
|
| -- Get only the wrappers
| implicit_wids :: TyThing -> [Id]
| -- C.f. HscTypes.mkImplicitBinds, but we do not include constructor
workers
| implicit_wids (ATyCon tc) = map dataConWrapId (tyConDataCons_maybe tc
| `orElse` [])
| implicit_wids other = []
|
| -- Get all other bindings
| implicit_ids :: TyThing -> [Id]
| implicit_ids (ATyCon tc) = tyConSelIds tc ++ tyConGenIds tc
| implicit_ids (AClass cl) = classSelIds cl
| implicit_ids other = []
| ----------
|
|
|
|
| Sincerely,
| Tobias
|
| _______________________________________________
| Glasgow-haskell-bugs mailing list
| Glasgow-haskell-bugs@xxxxxxxxxxx
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise