elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.48k stars 659 forks source link

error on correct code using `Identity a = a` #2252

Open lue-bird opened 2 years ago

lue-bird commented 2 years ago

When a function annotation includes a type that contains

type alias Identity a =
    a

with an inferred type variable

map : (a -> b) -> Identity a -> Identity b
map change =
    change

elm falsely throws an error

Something is off with the body of the `map` definition:

    map change = change
                 ^^^^^^
This `change` value is a:

    a -> b

But the type annotation on `map` says it should be:

    Identity a -> Identity b

(on "why and when would you could want Identity")

github-actions[bot] commented 2 years ago

Thanks for reporting this! To set expectations:

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