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

Composition of effectful functions typechecks when it shouldn't #3513

Open
runarorama opened this issue Oct 17, 2022 · 0 comments
Open

Composition of effectful functions typechecks when it shouldn't #3513

runarorama opened this issue Oct 17, 2022 · 0 comments

Comments

@runarorama
Copy link
Contributor

This typechecks, but shouldn't:

  IO.tryEval : '{g, IO, Exception} a ->{g, IO, Exception} a
  IO.tryEval = reraise << catchAll.impl

  IO.catchAll.impl : '{IO, Exception} a ->{IO} Either Failure a
  IO.catchAll.impl thunk =
    handle tryEval.impl '(catch thunk)
    with
      cases
        { x }                    -> x
        {Exception.raise f -> _} -> Left f

The argument to IO.tryEval requires an ability g, but the type of catchAll.impl should prohibit that.

Note that this does not typecheck:

  IO.tryEval : '{g, IO, Exception} a ->{g, IO, Exception} a
  IO.tryEval x = reraise (catchAll.impl x)

The type of << is:

  (Function.<<) : (b ->{𝕖} c) -> (a ->{𝕖} b) -> a ->{𝕖} c
  (Function.<<) f g x = f (g x)
@runarorama runarorama changed the title Composition on effectful functions typechecks when it shouldn't Composition of effectful functions typechecks when it shouldn't Oct 17, 2022
@dolio dolio added the snooze-1 label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants