-
-
Save forki/1450726 to your computer and use it in GitHub Desktop.
UndoMonad Calculator Example
This file contains hidden or 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
open System | |
open FSharpx.Undo | |
module Sample = | |
let rec handleInput<'a> = undoable { | |
match Console.ReadLine() with | |
| "undo" -> | |
let! _ = undo | |
() | |
| input -> | |
match Double.TryParse input with | |
| true,x -> do! combineWithCurrent (+) x | |
| _ -> () | |
let! currentVal = getCurrent | |
printfn "The current total is %O" currentVal | |
return! handleInput } | |
Sample.handleInput (empty 0.) |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fsprojects/FSharpx.Extras@9906eea