Source file semigroupoid.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
module Core (Req : Preface_specs.Semigroupoid.WITH_COMPOSE) = Req
module Operation (Core : Preface_specs.Semigroupoid.CORE) = struct
type ('a, 'b) t = ('a, 'b) Core.t
let compose_right_to_left f g = Core.compose f g
let compose_left_to_right f g = Core.compose g f
end
module Infix (Core : Preface_specs.Semigroupoid.CORE) = struct
type ('a, 'b) t = ('a, 'b) Core.t
let ( % ) f g = Core.compose f g
let ( <% ) f g = Core.compose f g
let ( %> ) f g = Core.compose g f
let ( <<< ) f g = Core.compose f g
let ( >>> ) f g = Core.compose g f
end
module Via_compose (Req : Preface_specs.Semigroupoid.WITH_COMPOSE) = struct
module Core = Core (Req)
include Core
include Operation (Core)
module Infix = Infix (Core)
include Infix
end
module Via
(Core : Preface_specs.Semigroupoid.CORE)
(Operation : Preface_specs.Semigroupoid.OPERATION)
(Infix : Preface_specs.Semigroupoid.INFIX) =
struct
include Core
include Operation
include Infix
module Infix = Infix
end
module From_monad (Monad : Preface_specs.Monad.CORE) = Via_compose (struct
type ('a, 'b) t = 'a -> 'b Monad.t
let compose f g = Monad.compose_left_to_right g f
end)
module Product (F : Preface_specs.SEMIGROUPOID) (G : Preface_specs.SEMIGROUPOID) =
Via_compose (struct
type ('a, 'b) t = ('a, 'b) F.t * ('a, 'b) G.t
let compose (x1, y1) (x2, y2) = (F.compose x1 x2, G.compose y1 y2)
end)