Created
June 4, 2024 07:49
-
-
Save jindraivanek/756a838b26fe4746bfb3df67de4b330c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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