compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Transmute value to arbitrary type with mutually recursive functions

Open 1derless opened this issue 3 years ago • 1 comments

Quick Summary: Mutually recursive functions can be used to transmute a value to an arbitrary type.

SSCCE

-- repl says f has type `a -> b -> c`
f x y = g x y
g x y = if False then f x y else y

eraseType : a -> b
eraseType x = f () x
  • Elm: 0.19.1
  • Browser: n/a
  • Operating System: Arch Linux

Additional Details

Ellie: https://ellie-app.com/jr8JcxccdXba1

I think the types of f and g should be a -> b -> b, and my Haskell compiler (ghc) agrees.

In addition, attempting to print the type of g in the repl causes the crash in the mutual recursion-related issue #2207.

1derless avatar Aug 25 '22 11:08 1derless

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 Aug 25 '22 11:08 github-actions[bot]