blob: c29f1929714857b6fc7a0de5f45c57921d952cbf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Error = struct
open Concepts.Condition
let not_admitting () =
condition "not-admitting" "A handle was expected to carry the admission protocol and did not"
empty
end
type violations = (string * Concepts.Tuple.t) list
class type implementation = object
method check : (violations, Concepts.Condition.condition) result
end
type Handle.protocol += Admission of implementation
type t = implementation
let make impl = Admission (impl :> implementation)
let from handle = Handle.into handle (function Admission impl -> Some impl | _ -> None)
let require handle = from handle |> Option.to_result ~none:(Error.not_admitting ())
let check i = Handle.invoke i (fun o -> o#check)
|