-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathabstraction-arrow.fsx
85 lines (60 loc) · 1.52 KB
/
abstraction-arrow.fsx
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
78
79
80
81
82
83
84
85
(*** hide ***)
// This block of code is omitted in the generated HTML documentation. Use
// it to define helpers that you do not want to show in the documentation.
(**
Arrow
=====
Arrow<'T, 'U> represents a process that takes as input something of type 'T and outputs something of type 'U.
___
Minimal complete definition
---------------------------
* ``arr f`` and ``first f``
*)
(**
static member Arr(f: 'T -> 'U) : 'Arrow<'T, 'U>
static member First (f: 'Arrow<'T, 'U>) : 'Arrow<('T * 'V),('U * 'V)>
*)
(**
Other operations
----------------
* ``second f``
*)
(**
static member Second (f: 'Arrow<'T, 'U>) : 'Arrow<('V * 'T),('V * 'U)>
*)
(**
* ``(***) f g``
*)
(**
static member ``***`` (f : 'Arrow<'T1,'U1>) (g : 'Arrow<'T2,'U2>) : 'Arrow<('T1 * 'T2),('U1 * 'U2)>
*)
(**
* ``(&&&) f g``
*)
(**
static member (&&&) (f : 'Arrow<'T,'U1>) (g : 'Arrow<'T,'U2>) : 'Arrow<'T,('U1 * 'U2)>
*)
(**
Rules
-----
*)
(**
arr id = id
arr (f >>> g) = arr f >>> arr g
first (arr f) = arr (first f)
first (f >>> g) = first f >>> first g
first f >>> arr fst = arr fst >>> f
first f >>> arr (id *** g) = arr (id *** g) >>> first f
first (first f) >>> arr assoc = arr assoc >>> first f
where assoc ((a,b),c) = (a,(b,c))
*)
(**
Concrete implementations
------------------------
From .Net/F#
- ``'T->'U``
- ``Func<'T,'U>``
From F#+
- [``Kleisli<'T, 'Monad<'U>>``](type-kleisli.html)
[Suggest another](https://github.com/fsprojects/FSharpPlus/issues/new) concrete implementation
*)