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
module Core (Req : Preface_specs.Category.WITH_ID_AND_COMPOSE) = Req
module Operation (Core : Preface_specs.Category.CORE) = struct
include Semigroupoid.Operation (Core)
end
module Infix (Core : Preface_specs.Category.CORE) = struct
include Semigroupoid.Infix (Core)
end
module Via_id_and_compose (Req : Preface_specs.Category.WITH_ID_AND_COMPOSE) =
struct
module Core = Core (Req)
include Core
include Operation (Core)
module Infix = Infix (Core)
include Infix
end
module Via
(Core : Preface_specs.Category.CORE)
(Operation : Preface_specs.Category.OPERATION)
(Infix : Preface_specs.Category.INFIX) =
struct
include Core
include Operation
include Infix
module Infix = Infix
end
module From_monad (Monad : Preface_specs.Monad.CORE) =
Via_id_and_compose (struct
type ('a, 'b) t = 'a -> 'b Monad.t
let id = Monad.return
let compose f g = Monad.compose_left_to_right g f
end)
module Over_semigroupoid
(G : Preface_specs.Semigroupoid.WITH_COMPOSE)
(Req : Preface_specs.Category.WITH_ID with type ('a, 'b) t = ('a, 'b) G.t) =
Via_id_and_compose (struct
type ('a, 'b) t = ('a, 'b) G.t
let id = Req.id
let compose = G.compose
end)
module Product (F : Preface_specs.CATEGORY) (G : Preface_specs.CATEGORY) =
Via_id_and_compose (struct
type ('a, 'b) t = ('a, 'b) F.t * ('a, 'b) G.t
let id = (F.id, G.id)
let compose (x1, y1) (x2, y2) = (F.compose x1 x2, G.compose y1 y2)
end)