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
71
72
73
74
75
76
77
type ('a, 'b) t = 'a -> 'b
include Preface_core.Fun
module Profunctor = Preface_make.Profunctor.Via_dimap (struct
type nonrec ('a, 'b) t = ('a, 'b) t
let dimap x y z = y % z % x
end)
module Strong =
Preface_make.Strong.Over_profunctor_via_fst
(Profunctor)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
let fst x (y, z) = (x y, z)
end)
module Choice =
Preface_make.Choice.Over_profunctor_via_left
(Profunctor)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
let left f = function
| Either.Left x -> Either.Left (f x)
| Either.Right x -> Either.Right x
;;
end)
module Closed =
Preface_make.Closed.Over_profunctor_via_closed
(Profunctor)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
let closed = Preface_core.Fun.compose_right_to_left
end)
module Semigroupoid = Preface_make.Semigroupoid.Via_compose (struct
type nonrec ('a, 'b) t = ('a, 'b) t
let compose = compose_right_to_left
end)
module Category =
Preface_make.Category.Over_semigroupoid
(Semigroupoid)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
let id x = x
end)
module Arrow = Preface_make.Arrow.From_strong_and_category (Strong) (Category)
module Arrow_choice =
Preface_make.Arrow_choice.Over_arrow_with_choose
(Arrow)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
open Preface_core.Shims
let case f g = Either.fold ~left:f ~right:g
let choose f g = case (Either.left % f) (Either.right % g)
end)
module Arrow_apply =
Preface_make.Arrow_apply.Over_arrow
(Arrow)
(struct
type nonrec ('a, 'b) t = ('a, 'b) t
let apply (f, x) = f x
end)