Source file proxy_encoder.ml
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module Impl : Meta.S with type 'a t = 'a Encoder.t =
struct
type 'a t = 'a Encoder.t
let ( <$> ) (bijection : ('a, 'b) Bijection.texn) p =
let open Encoder in
bijection.Bijection.of_ <$> p
let ( <*> ) pa pb =
let open Encoder in
pa <*> pb
let ( <|> ) pu pv =
let open Encoder in
pu <|> pv
let ( *> ) pu pe =
let open Encoder in
pu *> pe
let ( <* ) pe pu =
let open Encoder in
pe <* pu
let ( <$ ) pu bijection =
let open Encoder in
bijection.Bijection.to_ <$> pu
let ( $> ) pe bijection =
let open Encoder in
bijection.Bijection.of_ <$> pe
let fix = Encoder.fix
let nop = Encoder.nop
let any = Encoder.char
let fail err = Encoder.fail err
let pure ~compare v = Encoder.pure ~compare v
let take = Encoder.take
let peek = Encoder.peek
let skip _ = pure ~compare:(fun () () -> 0) ()
let const s = Encoder.const s
let commit = Encoder.commit
let while0 predicate = Encoder.while0 predicate
let while1 predicate = Encoder.while1 predicate
let bigstring_while0 predicate = Encoder.bigstring_while0 predicate
let bigstring_while1 predicate = Encoder.bigstring_while1 predicate
let buffer = Encoder.buffer
let bigstring_buffer = Encoder.bigstring_buffer
module Option =
struct
let (<$>) bijection p =
(Bijection.Exn.of_option bijection) <$> p
let ( $>)
: unit t -> (unit, 'a) Bijection.topt -> 'a t
= fun pe bijection ->
pe $> (Bijection.Exn.of_option bijection)
let (<$ )
: 'a t -> (unit, 'a) Bijection.topt -> unit t
= fun pu bijection ->
pu <$ (Bijection.Exn.of_option bijection)
end
end