Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant