Skip to content

Instantly share code, notes, and snippets.

@wires
Created November 10, 2011 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wires/1356424 to your computer and use it in GitHub Desktop.
Save wires/1356424 to your computer and use it in GitHub Desktop.
"server side" for Soq
Require Import Utf8 String ZArith.
(* IO is done through this JSON inductive type *)
Inductive JSON :=
| JObject : list (string * JSON) → JSON
| JArray : list JSON → JSON
| JString : string → JSON
| JNumber : Z → JSON
| JBool : bool → JSON
| JNull : JSON.
(* for your specific project you need to provide two functions,
from and to your datastructure
TODO: use lens
*)
Definition to_bool (input:JSON) : option bool :=
match input with
| JBool a => Some a
| _ => None
end.
Definition to_json (input: bool) : JSON := JBool input.
(* once safely in your domain, you can do what you want with the thing. *)
Definition f : bool → bool := negb.
(* This function is called by the python wrapper *)
Definition process (input:JSON) : JSON :=
match to_bool input with
| Some a => to_json (f a)
| None => JNull
end.
Eval compute in (process (JBool false)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment