Skip to content

Instantly share code, notes, and snippets.

@forki
Forked from dmohl/UndoMonadCalc.fs
Created December 9, 2011 08:23
Show Gist options
  • Save forki/1450726 to your computer and use it in GitHub Desktop.
Save forki/1450726 to your computer and use it in GitHub Desktop.
UndoMonad Calculator Example
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
@forki
Copy link
Author

forki commented Dec 9, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment