1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
type 'a t =
{ conv : 'a Repr.conv
; check : 'a Check.t
}
let make ~conv ~check = { conv; check }
let conv { conv; _ } = conv
let check { check; _ } = check
let invmap f g { conv; check } =
{ check = (fun x -> x |> check |> Result.map f)
; conv = (fun x -> x |> g |> conv)
}
;;
let refine f g { conv; check } =
{ check = (fun x -> Result.bind (check x) f)
; conv = (fun x -> x |> g |> conv)
}
;;