You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The REPL seems to be able to generate the definition for specialized linear map definition for List, but if we add a second recursive parameter (such as required for a binary tree), then generate definition loops forever.
I get a crash due to stack overflow, it's interesting that you don't see that behaviour! Or maybe you compiled Idris2 with -O2 which might change one of the functions to be tail recursive?
In any case - this isn't an infinite loop, but rather the search space getting too big because the tree is branching. The expression search really is very simple, and just does a brute force search of the whole space. There's probably things we can do to prune the tree and make this sort of search work better, but in the short term I think the best we can do is cut off the search and say the problem is too big.
Part of the reason this problem gets big is that it doesn't look at how linear bindings affect the result until after generating a candidate expression. So there's a lot more candidates to check than there should be.
The REPL seems to be able to generate the definition for specialized linear map definition for
List
, but if we add a second recursive parameter (such as required for a binary tree), then generate definition loops forever.Steps to Reproduce
Please see https://gist.github.com/vladciobanu/a9509be6e005312af698a03d324cc0d9 for a trivial reproduction example. The code includes the
List
version to showcase the differences.Expected Behavior
Generate the correct implementation, or at least report it can't.
Observed Behavior
Infinite loop.
Possibly related, but unsure. Let me know if I should create a different issue for this.
If I change the definition of
Tree
toand try to generate its map function, I get:
If I change the definition to
Then it reports it can't find a definition for the same
mapTree
, although we can write:The text was updated successfully, but these errors were encountered: