Closed paulyoung closed 7 years ago
I haven't cracked this nut yet, but I think this is the shortest pair of mutually recursive bindings:
module Example where
f :: forall a. a -> a
f x = g x
g :: forall a. a -> a
g x = f x
That is represented as this corefn:
{
"Example": {
"builtWith": "0.10.3",
"exports": [ "f", "g" ],
"imports": [ "Prim", "Example" ],
"foreign": [],
"decls": [
{
"g": [
"Abs",
"x",
[
"App",
[ "Var", "Example.f" ],
[ "Var", "x" ]
]
],
"f": [
"Abs",
"x",
[
"App",
[ "Var", "Example.g" ],
[ "Var", "x" ]
]
]
}
]
}
}
Thanks @tfausak! I'll give this a try soon.
I'm a bit surprised to see the module itself in the import list, but I guess it sort of makes sense.
I'm currently filtering out the import for Prim
in some backend implementations. I suppose I'd need to do the same.
I think the module shows up in its own import list because the references are fully qualified. You end up with essentially f = \ x -> Example.g x
instead of the simpler but potentially ambiguous f = \ x -> g x
.
@tfausak I made a bit of progress on this in #35.
As explained in https://github.com/paulyoung/purescript-corefn/pull/25#issuecomment-269015471, mutually recursive bindings are not yet supported (mostly due to lack of a minimal example to test against).