diff options
Diffstat (limited to 'lib/modes.ml')
| -rw-r--r-- | lib/modes.ml | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/lib/modes.ml b/lib/modes.ml deleted file mode 100644 index 3d0e354..0000000 --- a/lib/modes.ml +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | type mode = Normal | Insert | ||
| 2 | type t = mode | ||
| 3 | type state = int | ||
| 4 | type 'a state_monad = state -> 'a * state | ||
| 5 | |||
| 6 | let run (f : 'a state_monad) (s : state) : 'a = f s |> fst | ||
| 7 | let return (a : 'a) : 'a state_monad = fun s -> (a, s) | ||
| 8 | |||
| 9 | let ( >>= ) (f : 'a state_monad) (g : 'a -> 'b state_monad) : 'b state_monad = | ||
| 10 | fun s -> | ||
| 11 | let a, s' = f s in | ||
| 12 | g a s' | ||
| 13 | |||
| 14 | let draw () : unit state_monad = return () | ||
| 15 | let get_keypress () : char state_monad = return 'a' | ||
| 16 | let handle_key (_ : char) : unit state_monad = return () | ||
| 17 | let rec loop () = () |> draw >>= get_keypress >>= handle_key >>= loop | ||
| 18 | let test = run (loop ()) 0 | ||
