Skip to content

Instantly share code, notes, and snippets.

@jindraivanek
Created June 4, 2024 07:49
Show Gist options
  • Save jindraivanek/756a838b26fe4746bfb3df67de4b330c to your computer and use it in GitHub Desktop.
Save jindraivanek/756a838b26fe4746bfb3df67de4b330c to your computer and use it in GitHub Desktop.
#r "nuget: Elmish"
open Elmish
type Msg =
| Do
| Done of int
| Error of exn
let init _ = 0, Cmd.ofMsg Do
let update msg state =
match msg with
| Do ->
printfn "Do"
// this correctly raise exception
//state, Cmd.ofMsg (Done state)
// exception is not raised for Cmd.OfAsync.* functions
state, Cmd.OfAsync.either (fun x -> async { return x + 1 }) state Done Error
| Done i ->
failwith "BOOM"
printfn "Done: %i" i
i, Cmd.none
| Error e ->
printfn "Error: %A" e
state, Cmd.none
let view _ _ = ()
Program.mkProgram init update view
|> Program.withConsoleTrace
|> Program.run
printfn "Exception was not raised"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment