Skip to content

Instantly share code, notes, and snippets.

@zarkzork
Created December 1, 2014 09:41
Show Gist options
  • Save zarkzork/f4f4c30f5f6009697e53 to your computer and use it in GitHub Desktop.
Save zarkzork/f4f4c30f5f6009697e53 to your computer and use it in GitHub Desktop.
sample schema for typtypio
(* schema *)
module type Schema = sig
type t
end
module Schema = struct
type t
type value_type =
| StringVal
| IntVal
| DateVal
type schema_hash = (string * value_type) list
type schema =
| Empty
| Val of schema_hash
| List of schema_hash list
module type Schemable = sig
val schema : schema
end
module Make_Schema(M : Schemable) = struct
type t;;
let schema = M.schema;;
end
module EmptySchema : Schema = Make_Schema(struct let schema = Empty end);;
end
(* Route defenition *)
module type Route = sig
type verb = | Head | Get | Post | Put | Patch | Delete
type session = Session of string
type cache = None | NoCache | Etag of string | Seconds of int
type url = {
name: string option;
param: string option
}
type permission =
| Allow
| Custom of (session -> bool)
type url_param = string option
type 'a result =
| Result of 'a option * cache
| Error of int * string
module In : Schema
module Out: Schema
val description: string
val path: verb * url
val permission: permission
val operation: session -> url_param -> In.t -> Out.t result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment