Skip to content

Instantly share code, notes, and snippets.

@jroesch
Created September 6, 2016 01:54
Show Gist options
  • Save jroesch/68d3fc08260d59fd479f33ee689f3835 to your computer and use it in GitHub Desktop.
Save jroesch/68d3fc08260d59fd479f33ee689f3835 to your computer and use it in GitHub Desktop.
definition position := nat
inductive result (I : Type) : Type -> Type
| fail : Π {R}, I -> list string -> string -> result R
| partial : Π {R}, (I -> result R) -> result R
| done : Π {R}, I -> R -> result R
open result
definition result.map {A B I : Type} (f : A → B) : result I A -> result I B
| result.map (fail input contexts msg) := (fail input contexts msg)
| result.map (partial k) := partial (fun x, result.map (k x))
| result.map (done input res) := done input (f res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment