compiler icon indicating copy to clipboard operation
compiler copied to clipboard

calling function recursively with different type arguments

Open indique opened this issue 3 years ago • 2 comments

When calling a function recursively, you can only call it with the same type arguments.

recursive : any -> Never
recursive _ =
    recursive "specific"

We try to define a recursive function (infinite to make it simpler). When we call the recursive function with a specific type argument, elm complains:

The 1st argument to `recursive` is not what I expect:
2|     recursive "specific"
                 ^^^^^^^^^^
This argument is a string of type:
   String
But `recursive` needs the 1st argument to be:
   any

In short, support polymorphic recursion.

  • Elm 0.19.1
  • Operating System: Ubuntu 20.04.2 LTS

indique avatar Mar 08 '21 15:03 indique

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

github-actions[bot] avatar Mar 08 '21 15:03 github-actions[bot]

same as https://github.com/elm/compiler/issues/2275 More detail in https://github.com/elm/compiler/issues/1964

lue-bird avatar Sep 03 '22 05:09 lue-bird