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

Be able to perform unhandled effects #11

Merged
merged 4 commits into from
Sep 19, 2023
Merged

Conversation

dinosaure
Copy link
Contributor

Currently, this PR tries to fix the issue #10: what Miou should do when we catch another effect. I did a try with this code:

type _ Effect.t += Foo : unit Effect.t

let prgm () =
  let prm = Miou.call_cc @@ fun () -> Effect.perform Foo in
  Miou.await_exn prm

let handler fn v =
  let open Effect.Deep in
  let retc = Fun.id in
  let exnc = raise in
  let effc : type c. c Effect.t -> ((c, 'a) continuation -> 'b) option =
    function
    | Foo -> Some (fun k -> continue k ())
    | _ -> None
  in
  match_with fn v { retc; exnc; effc }

let () = handler (fun () -> Miou.run prgm) ()

So we can plug an other handler on top of Miou which handle our effects. However, we keep the same rule about our "quanta": a program is suspended when it emits one effect (even if the effect is not handled by Miou). The current issue is about parallel task. Indeed, the handler is only well know by dom0 but if we use Miou.call, we will get an exception. We can figure out about an optional argument passed by Miou.run which will "protect" tasks with our handler on other domains.

/cc @patricoferris (who asking) @hannesm (who is interested by that)

@dinosaure dinosaure marked this pull request as ready for review September 15, 2023 08:32
@dinosaure
Copy link
Contributor Author

It seems that nobody has an strong opinion about that, let's merge and see what happens with such interface.

@dinosaure dinosaure merged commit 664e8e2 into main Sep 19, 2023
1 check passed
@dinosaure dinosaure deleted the handle-other-effects branch September 19, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant