Commit 374b638d authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Adding new application framework

parent b392292b5328
module StringMap = Map.Make(String);;
(* Exception when the application is in a bad state *)
exception BadState of string
(* A piece of data that has to be fetched *)
type requestedData =
(* A schema that has to be fetched *)
......@@ -62,6 +65,13 @@ type resource = {
data: Hypermedia.entityValue option;
}
let schema_of resource = match resource.schema with
| None -> raise (BadState "Expected a schema for the resource")
| Some(schema) -> schema
let data_of resource = match resource.data with
| None -> raise (BadState "Expected data for the resource")
| Some(data) -> data
(* Type of a rendering function *)
......
(* When an assertion failed *)
exception AssertFail of string
type reference = { ref: string }
type schemaLink = {
......@@ -51,6 +54,23 @@ and entityValue =
| ValueObject of entity
(* Module for schema manipulation *)
module Schema = struct
let as_root schema = match schema with
| RootType(x) -> x
| _ -> raise (AssertFail "Not a root schema")
let as_array schema = match schema with
| ArrayType(x) -> x
| _ -> raise (AssertFail "Not an array schema")
let as_object schema = match schema with
| ObjectType(x) -> x
| _ -> raise (AssertFail "Not an object schema")
let as_primitive schema = match schema with
| PrimitiveType(x) -> x
| _ -> raise (AssertFail "Not a primitive type")
end
(* Module for entity manipulation *)
module Entity = struct
let get entity key = begin
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment