Skip to content

Commit a72f405

Browse files
committed
New naming convention
1 parent 29d3ff3 commit a72f405

17 files changed

+409
-377
lines changed

docsrc/content/abstraction-par-applicative.fsx docsrc/content/abstraction-zipapplicative.fsx

+24-19
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,42 @@
44
#r @"../../src/FSharpPlus/bin/Release/netstandard2.0/FSharpPlus.dll"
55

66
(**
7-
Par-Applicative
8-
===============
9-
A functor with application, providing operations to embed pure expressions (``preturn``), parallel computations and combine their results (``</>``).
7+
ZipApplicative
8+
==============
9+
A functor with application, providing operations to embed pure expressions (``pur``), run computations pointwise and/or paralell and combine their results (``<.>``).
1010
___
1111
Minimal complete definition
1212
---------------------------
13-
* ``preturn x`` &nbsp; / &nbsp; ``result x``
14-
* ``(</>) f x``
13+
* ``pur x`` &nbsp; . &nbsp; ``result x``
14+
* ``(<.>) f x``
1515
*)
1616
(**
17-
static member ParReturn (x: 'T) : 'Applicative<'T>
18-
static member (</>) (f: 'Applicative<'T -> 'U>, x: 'Applicative<'T>) : 'Applicative<'U>
17+
static member Pure (x: 'T) : 'ZipApplicative<'T>
18+
static member (<.>) (f: 'ZipApplicative<'T -> 'U>, x: 'ZipApplicative<'T>) : 'ZipApplicative<'U>
1919
*)
2020
(**
21-
Note: ``preturn`` can't be used outside computation expressions, use ``result`` instead.
2221
2322
2423
Other operations
2524
----------------
2625
27-
* ``plift2``
26+
* ``zip``
2827
*)
2928
(**
30-
static member ParLift2 (f: 'T1 -> 'T2 -> 'T, x1: 'Applicative<'T1>, x2: 'Applicative<'T2>) : 'Applicative<'T>
29+
static member Zip (x1: 'ZipApplicative<'T1>, x2: 'ZipApplicative<'T2>) : 'ZipApplicative<'T1 * 'T2>
30+
*)
31+
32+
* ``pmap2``
33+
*)
34+
(**
35+
static member Map2 (f: 'T1 -> 'T2 -> 'T, x1: 'ZipApplicative<'T1>, x2: 'ZipApplicative<'T2>) : 'ZipApplicative<'T>
3136
*)
3237

3338
(**
34-
* ``plift3``
39+
* ``pmap3``
3540
*)
3641
(**
37-
static member ParLift3 (f: 'T1 -> 'T2 -> 'T3 -> 'T, x1: 'Applicative<'T1>, x2: 'Applicative<'T2>, x3: 'Applicative<'T3>) : 'Applicative<'T>
42+
static member Map3 (f: 'T1 -> 'T2 -> 'T3 -> 'T, x1: 'ZipApplicative<'T1>, x2: 'ZipApplicative<'T2>, x3: 'ZipApplicative<'T3>) : 'ZipApplicative<'T>
3843
*)
3944

4045
(**
@@ -44,17 +49,17 @@ Rules
4449
-----
4550
*)
4651
(**
47-
presult id </> v = v
48-
presult (<<) </> u </> v </> w = u </> (v </> w)
49-
presult f <*> presult x = presult (f x)
50-
u <*> presult y = presult ((|>) y) </> u
52+
pur id <.> v = v
53+
pur (<<) <.> u <.> v <.> w = u <.> (v <.> w)
54+
pur f <*> pur x = pur (f x)
55+
u <*> pur y = pur ((|>) y) <.> u
5156
*)
5257
(**
5358
Related Abstractions
5459
--------------------
55-
- [Functor](abstraction-functor.html): A parallel applicative is a functor whose ``map`` operation can be splitted in ``preturn`` and ``(</>)`` operations,
60+
- [Functor](abstraction-functor.html): A zipZipApplicative is a functor whose ``map`` operation can be splitted in ``pur`` and ``(<.>)`` operations,
5661
57-
- [Applicative](abstraction-applicative.html) : Parallel Applicatives are applicatives which usually don't form a [Monad](abstraction-monad.html).
62+
- [ZipApplicative](abstraction-applicative.html) : ZipZipApplicatives are applicatives which usually don't form a [Monad](abstraction-monad.html).
5863
5964
Concrete implementations
6065
------------------------
@@ -81,7 +86,7 @@ From F#+
8186
8287
- [``NonEmptySeq<'T>``]
8388
- [``NonEmptyList<'T>``](type-nonempty.html)
84-
- [``Compose<'Applicative1<'Applicative2<'T>>>``](type-compose.html)
89+
- [``Compose<'ZipApplicative1<'ZipApplicative2<'T>>>``](type-compose.html)
8590
8691
(*) The operation is the same as that for the normal applicative
8792

src/FSharpPlus/Builders.fs

+15-15
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,24 @@ module GenericBuilders =
210210
member _.Run x : '``Applicative1<Applicative2<Applicative3<'T>>>`` = x
211211

212212

213-
/// Generic Parallel Applicative CE builder.
214-
type ParallelBuilder<'``applicative<'t>``> () =
213+
/// Generic ZipApplicative CE builder.
214+
type ZipApplicativeBuilder<'``applicative<'t>``> () =
215215
member _.ReturnFrom (expr) = expr : '``applicative<'t>``
216-
member inline _.Return (x: 'T) = ParReturn.Invoke x : '``Applicative<'T>``
217-
member inline _.Yield (x: 'T) = ParReturn.Invoke x : '``Applicative<'T>``
216+
member inline _.Return (x: 'T) = pur x : '``Applicative<'T>``
217+
member inline _.Yield (x: 'T) = pur x : '``Applicative<'T>``
218218
member inline _.BindReturn(x, [<InlineIfLambda>]f) = map f x : '``Applicative<'U>``
219-
member inline _.MergeSources (t1: '``Applicative<'T>``, t2: '``Applicative<'U>``) : '``Applicative<'T * 'U>`` = ParLift2.Invoke tuple2 t1 t2
220-
member inline _.MergeSources3 (t1: '``Applicative<'T>``, t2: '``Applicative<'U>``, t3: '``Applicative<'V>``) : '``Applicative<'T * 'U * 'V>`` = ParLift3.Invoke tuple3 t1 t2 t3
221-
member _.Run f = f : '``Applicative<'T>``
219+
member inline _.MergeSources (t1: '``Applicative<'T>``, t2: '``Applicative<'U>``) : '``Applicative<'T * 'U>`` = map2 tuple2 t1 t2
220+
member inline _.MergeSources3 (t1: '``Applicative<'T>``, t2: '``Applicative<'U>``, t3: '``Applicative<'V>``) : '``Applicative<'T * 'U * 'V>`` = map3 tuple3 t1 t2 t3
221+
member _.Run f : '``Applicative<'T>`` = f
222222

223-
/// Generic 2 layers Parallel Applicative CE builder.
224-
type ParallelBuilder2<'``applicative1<applicative2<'t>>``> () =
223+
/// Generic 2 layers ZipApplicative CE builder.
224+
type ZipApplicativeBuilder2<'``applicative1<applicative2<'t>>``> () =
225225
member _.ReturnFrom expr : '``applicative1<applicative2<'t>>`` = expr
226-
member inline _.Return (x: 'T) : '``Applicative1<Applicative2<'T>>`` = (presult >> presult) x
227-
member inline _.Yield (x: 'T) : '``Applicative1<Applicative2<'T>>`` = (presult >> presult) x
226+
member inline _.Return (x: 'T) : '``Applicative1<Applicative2<'T>>`` = (pur >> pur) x
227+
member inline _.Yield (x: 'T) : '``Applicative1<Applicative2<'T>>`` = (pur >> pur) x
228228
member inline _.BindReturn (x: '``Applicative1<Applicative2<'T>>``, [<InlineIfLambda>]f: _ -> _) : '``Applicative1<Applicative2<'U>>`` = (map >> map) f x
229-
member inline _.MergeSources (t1, t2) : '``Applicative1<Applicative2<'T>>`` = (plift2 >> plift2) tuple2 t1 t2
230-
member inline _.MergeSources3 (t1, t2, t3) : '``Applicative1<Applicative2<'T>>`` = (plift3 >> plift3) tuple3 t1 t2 t3
229+
member inline _.MergeSources (t1, t2) : '``Applicative1<Applicative2<'T>>`` = (map2 >> map2) tuple2 t1 t2
230+
member inline _.MergeSources3 (t1, t2, t3) : '``Applicative1<Applicative2<'T>>`` = (map3 >> map3) tuple3 t1 t2 t3
231231
member _.Run x : '``Applicative1<Applicative2<'T>>`` = x
232232

233233
/// Creates a (lazy) monadic computation expression with side-effects (see http://fsprojects.github.io/FSharpPlus/computation-expressions.html for more information)
@@ -246,9 +246,9 @@ module GenericBuilders =
246246
let applicative3<'``Applicative1<Applicative2<Applicative3<'T>>>``> = ApplicativeBuilder3<'``Applicative1<Applicative2<Applicative3<'T>>>``> ()
247247

248248
/// Creates a parallel applicative computation expression.
249-
let par<'``Applicative<'T>``> = ParallelBuilder<'``Applicative<'T>``> ()
249+
let zapp<'``Applicative<'T>``> = ZipApplicativeBuilder<'``Applicative<'T>``> ()
250250

251251
/// Creates a parallel applicative computation expression which compose effects of two Applicatives.
252-
let par2<'``Applicative1<Applicative2<'T>>``> = ParallelBuilder2<'``Applicative1<Applicative2<'T>>``> ()
252+
let zapp2<'``Applicative1<Applicative2<'T>>``> = ZipApplicativeBuilder2<'``Applicative1<Applicative2<'T>>``> ()
253253

254254
#endif

src/FSharpPlus/Control/Applicative.fs

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ type Lift2 =
109109
static member inline Lift2 (f, ((a: 'Monoid, x: 'T) , (b: 'Monoid, y: 'U) ), _mthd: Lift2) = Plus.Invoke a b, f x y
110110
static member inline Lift2 (f, (struct (a: 'Monoid, x: 'T), struct (b: 'Monoid, y: 'U)), _mthd: Lift2) = struct (Plus.Invoke a b, f x y)
111111
#if !FABLE_COMPILER
112-
static member Lift2 (f, (x: Task<'T> , y: Task<'U> ), _mthd: Lift2) = Task.map2 f x y
112+
static member Lift2 (f, (x: Task<'T> , y: Task<'U> ), _mthd: Lift2) = Task.lift2 f x y
113113
#endif
114114
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
115-
static member Lift2 (f, (x: ValueTask<'T> , y: ValueTask<'U> ), _mthd: Lift2) = ValueTask.map2 f x y
115+
static member Lift2 (f, (x: ValueTask<'T> , y: ValueTask<'U> ), _mthd: Lift2) = ValueTask.lift2 f x y
116116
#endif
117-
static member Lift2 (f, (x , y ), _mthd: Lift2) = Async.map2 f x y
117+
static member Lift2 (f, (x , y ), _mthd: Lift2) = Async.lift2 f x y
118118
static member Lift2 (f, (x , y ), _mthd: Lift2) = Option.map2 f x y
119119

120120
#if !FABLE_COMPILER
@@ -158,12 +158,12 @@ type Lift3 =
158158
static member inline Lift3 (f, ((a: 'Monoid, x: 'T) , (b: 'Monoid, y: 'U) , (c: 'Monoid, z: 'U) ), _mthd: Lift3) = Plus.Invoke (Plus.Invoke a b) c, f x y z
159159
static member inline Lift3 (f, (struct (a: 'Monoid, x: 'T), struct (b: 'Monoid, y: 'U), struct (c: 'Monoid, z: 'U)), _mthd: Lift3) = struct (Plus.Invoke (Plus.Invoke a b) c, f x y z)
160160
#if !FABLE_COMPILER
161-
static member Lift3 (f, (x: Task<'T> , y: Task<'U> , z: Task<'V> ), _mthd: Lift3) = Task.map3 f x y z
161+
static member Lift3 (f, (x: Task<'T> , y: Task<'U> , z: Task<'V> ), _mthd: Lift3) = Task.lift3 f x y z
162162
#endif
163163
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
164-
static member Lift3 (f, (x: ValueTask<'T> , y: ValueTask<'U> , z: ValueTask<'V> ), _mthd: Lift3) = ValueTask.map3 f x y z
164+
static member Lift3 (f, (x: ValueTask<'T> , y: ValueTask<'U> , z: ValueTask<'V> ), _mthd: Lift3) = ValueTask.lift3 f x y z
165165
#endif
166-
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Async.map3 f x y z
166+
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Async.lift3 f x y z
167167
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Option.map3 f x y z
168168

169169
#if !FABLE_COMPILER

src/FSharpPlus/Control/Functor.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ type Zip =
219219
static member Zip ((x: option<'T> , y: option<'U> , _output: option<'T*'U> ), _mthd: Zip) = Option.zip x y
220220
static member Zip ((x: voption<'T> , y: voption<'U> , _output: voption<'T*'U> ), _mthd: Zip) = ValueOption.zip x y
221221
static member Zip ((x: Result<'T, 'Error> , y: Result<'U, 'Error> , _output: Result<'T * 'U, 'Error> ), _mthd: Zip) = Result.zip x y
222-
static member Zip ((x: Async<'T> , y: Async<'U> , _output: Async<'T*'U> ), _mthd: Zip) = Async.zip x y
222+
static member Zip ((x: Async<'T> , y: Async<'U> , _output: Async<'T*'U> ), _mthd: Zip) = Async.zipSequentially x y
223223
#if !FABLE_COMPILER
224-
static member Zip ((x: Task<'T> , y: Task<'U> , _output: Task<'T*'U> ), _mthd: Zip) = Task.zip x y
224+
static member Zip ((x: Task<'T> , y: Task<'U> , _output: Task<'T*'U> ), _mthd: Zip) = Task.zipSequentially x y
225225
#endif
226226
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
227-
static member Zip ((x: ValueTask<'T> , y: ValueTask<'U> , _output: ValueTask<'T*'U> ), _mthd: Zip) = ValueTask.zip x y
227+
static member Zip ((x: ValueTask<'T> , y: ValueTask<'U> , _output: ValueTask<'T*'U> ), _mthd: Zip) = ValueTask.zipSequentially x y
228228
#endif
229229

230230
static member inline Invoke (source1: '``ZipFunctor<'T1>``) (source2: '``ZipFunctor<'T2>``) =

src/FSharpPlus/Control/MonadOps.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module internal MonadOps =
88
let inline (>>=) x f = Bind.Invoke x f
99
let inline result x = Return.Invoke x
1010
let inline (<*>) f x = Apply.Invoke f x
11-
let inline presult x = ParReturn.Invoke x
12-
let inline (</>) f x = ParApply.Invoke f x
11+
let inline pur x = Pure.Invoke x
12+
let inline (<.>) f x = ZipApply.Invoke f x
1313
let inline (<|>) x y = Append.Invoke x y
1414
let inline (>=>) (f: 'a->'``Monad<'b>``) (g: 'b->'``Monad<'c>``) (x: 'a) : '``Monad<'c>`` = f x >>= g
1515

src/FSharpPlus/Control/Monoid.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ type Plus with
116116
#if !FABLE_COMPILER
117117
type Plus with
118118

119-
static member inline ``+`` (x: 'a Task, y: 'a Task, [<Optional>]_mthd: Plus) = Task.map2 Plus.Invoke x y
119+
static member inline ``+`` (x: 'a Task, y: 'a Task, [<Optional>]_mthd: Plus) = Task.lift2 Plus.Invoke x y
120120
#endif
121121

122122
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
123123
type Plus with
124124

125-
static member inline ``+`` (x: 'a ValueTask, y: 'a ValueTask, [<Optional>]_mthd: Plus) = ValueTask.map2 Plus.Invoke x y
125+
static member inline ``+`` (x: 'a ValueTask, y: 'a ValueTask, [<Optional>]_mthd: Plus) = ValueTask.lift2 Plus.Invoke x y
126126

127127
#endif
128128

@@ -138,7 +138,7 @@ type Plus with
138138

139139
static member inline ``+`` (f: 'T->'Monoid, g: 'T->'Monoid, [<Optional>]_mthd: Plus) = (fun x -> Plus.Invoke (f x) (g x)) : 'T->'Monoid
140140

141-
static member inline ``+`` (x: 'S Async , y: 'S Async , [<Optional>]_mthd: Plus) = Async.map2 Plus.Invoke x y
141+
static member inline ``+`` (x: 'S Async , y: 'S Async , [<Optional>]_mthd: Plus) = Async.lift2 Plus.Invoke x y
142142

143143
static member inline ``+`` (x: 'a Expr , y: 'a Expr , [<Optional>]_mthd: Plus) : 'a Expr =
144144
let inline f (x: 'a) : 'a -> 'a = Plus.Invoke x

0 commit comments

Comments
 (0)