Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checking bug #204

Open
jmackie opened this issue Feb 18, 2023 · 0 comments
Open

Type checking bug #204

jmackie opened this issue Feb 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jmackie
Copy link
Member

jmackie commented Feb 18, 2023

module Wut exports (..)


type Result(a, e) =
    | Ok(a)
    | Err(e)

map_result = fn (result: Result(a, e), f: (a) -> b): Result(b, e) ->
    match result with
    | Ok(a) -> Ok(f(a))
    | Err(err) -> Err(err)
    end

type Decoder(input, output) = Decoder((input) -> Result(output, Unit))

type alias StringDecoder(output) = Decoder(String, output)

-- This does two strange things:
--   * an incorrect type error
--   * warns about a redundant match pattern (maybe the root cause)
-- Both of which go away when you don't use the `StringDecoder` alias...
huh = fn (Decoder(decode): StringDecoder(a)): StringDecoder(Array(a)) ->
    Decoder(fn (s) -> map_result(decode(s), fn (a) -> [a]))

wut = fn (Decoder(decode): Decoder(String, a)): Decoder(String, Array(a)) ->
    Decoder(fn (s) -> map_result(decode(s), fn (a) -> [a]))

:scratches-head:

@jmackie jmackie added the bug Something isn't working label Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant