Skip to content

Commit 74c69e5

Browse files
committed
Continuation from #552
1 parent 6032264 commit 74c69e5

File tree

12 files changed

+181
-146
lines changed

12 files changed

+181
-146
lines changed

src/FSharpPlus/Builders.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace FSharpPlus
1818
module GenericBuilders =
1919

2020
open FSharpPlus.Operators
21-
open FSharpPlus.Data
2221

2322
// Idiom brackets
2423
type Ii = Ii

src/FSharpPlus/Control/Alternative.fs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace FSharpPlus.Control
1010

1111
open System.Runtime.InteropServices
1212
open FSharpPlus
13-
open FSharpPlus.Data
1413
open FSharpPlus.Internals
1514

1615

@@ -38,8 +37,6 @@ type Empty with
3837
type Append =
3938
inherit Default1
4039
static member ``<|>`` (x: 'T seq , y , [<Optional>]_mthd: Default2) = Seq.append x y
41-
static member ``<|>`` (x: 'T NonEmptySeq , y , [<Optional>]_mthd: Default2) = NonEmptySeq.append x y
42-
4340
static member inline ``<|>`` (x: '``Alt<'T>`` , y: '``Alt<'T>``, [<Optional>]_mthd: Default1) = (^``Alt<'T>`` : (static member (<|>) : _*_ -> _) x, y) : '``Alt<'T>``
4441
static member inline ``<|>`` (_: ^t when ^t: null and ^t: struct , _, _mthd: Default1) = ()
4542

@@ -114,14 +111,6 @@ type Choice =
114111
res <- Append.Invoke res e.Current
115112
res
116113

117-
static member inline Choice (x: ref<NonEmptySeq<'``Alternative<'T>``>>, _mthd: Choice) =
118-
use e = x.Value.GetEnumerator ()
119-
e.MoveNext() |> ignore
120-
let mutable res = e.Current
121-
while e.MoveNext() && not (IsAltLeftZero.Invoke res) do
122-
res <- Append.Invoke res e.Current
123-
res
124-
125114
static member inline Choice (x: ref<list<'``Alternative<'T>``>>, _mthd: Choice) =
126115
use e = (List.toSeq x.Value ).GetEnumerator ()
127116
let mutable res = Empty.Invoke ()

src/FSharpPlus/Control/Applicative.fs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open Microsoft.FSharp.Quotations
88

99
open FSharpPlus.Internals
1010
open FSharpPlus
11-
open FSharpPlus.Data
1211

1312

1413
type Apply =
@@ -18,7 +17,6 @@ type Apply =
1817

1918
static member ``<*>`` (struct (f: Lazy<'T->'U> , x: Lazy<'T> ) , _output: Lazy<'U> , [<Optional>]_mthd: Apply) = Lazy.apply f x : Lazy<'U>
2019
static member ``<*>`` (struct (f: seq<_> , x: seq<'T> ) , _output: seq<'U> , [<Optional>]_mthd: Apply) = Seq.apply f x : seq<'U>
21-
static member ``<*>`` (struct (f: NonEmptySeq<_> , x: NonEmptySeq<'T> ) , _output: NonEmptySeq<'U> , [<Optional>]_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U>
2220
static member ``<*>`` (struct (f: IEnumerator<_> , x: IEnumerator<'T> ) , _output: IEnumerator<'U> , [<Optional>]_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U>
2321
static member ``<*>`` (struct (f: list<_> , x: list<'T> ) , _output: list<'U> , [<Optional>]_mthd: Apply) = List.apply f x : list<'U>
2422
static member ``<*>`` (struct (f: _ [] , x: 'T [] ) , _output: 'U [] , [<Optional>]_mthd: Apply) = Array.apply f x : 'U []
@@ -101,8 +99,7 @@ type Lift2 =
10199
inherit Default1
102100

103101
static member Lift2 (f, (x: Lazy<_> , y: Lazy<_> ), _mthd: Lift2) = Lazy.map2 f x y
104-
static member Lift2 (f, (x: seq<_> , y: seq<_> ), _mthd: Lift2) = Seq.lift2 f x y
105-
static member Lift2 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> ), _mthd: Lift2) = NonEmptySeq.lift2 f x y
102+
static member Lift2 (f, (x: seq<_> , y: seq<_> ), _mthd: Lift2) = Seq.lift2 f x y
106103
static member Lift2 (f, (x: IEnumerator<_> , y: IEnumerator<_> ), _mthd: Lift2) = Enumerator.map2 f x y
107104
static member Lift2 (f, (x , y ), _mthd: Lift2) = List.lift2 f x y
108105
static member Lift2 (f, (x , y ), _mthd: Lift2) = Array.lift2 f x y
@@ -150,8 +147,7 @@ type Lift3 =
150147
inherit Default1
151148

152149
static member Lift3 (f, (x: Lazy<_> , y: Lazy<_> , z: Lazy<_> ), _mthd: Lift3) = Lazy.map3 f x y z
153-
static member Lift3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Lift3) = Seq.lift3 f x y z
154-
static member Lift3 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> , z: NonEmptySeq<_> ), _mthd: Lift3) = NonEmptySeq.lift3 f x y z
150+
static member Lift3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Lift3) = Seq.lift3 f x y z
155151
static member Lift3 (f, (x: IEnumerator<_> , y: IEnumerator<_> , z: IEnumerator<_> ), _mthd: Lift3) = Enumerator.map3 f x y z
156152
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = List.lift3 f x y z
157153
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Array.lift3 f x y z
@@ -197,8 +193,7 @@ type Lift3 with
197193
type IsLeftZero =
198194
inherit Default1
199195

200-
static member IsLeftZero (t: ref<seq<_>> , _mthd: IsLeftZero) = Seq.isEmpty t.Value
201-
static member IsLeftZero (_: ref<NonEmptySeq<_>>, _mthd: IsLeftZero) = false
196+
static member IsLeftZero (t: ref<seq<_>> , _mthd: IsLeftZero) = Seq.isEmpty t.Value
202197
static member IsLeftZero (t: ref<list<_>> , _mthd: IsLeftZero) = List.isEmpty t.Value
203198
static member IsLeftZero (t: ref<array<_>> , _mthd: IsLeftZero) = Array.isEmpty t.Value
204199
static member IsLeftZero (t: ref<option<_>> , _mthd: IsLeftZero) = Option.isNone t.Value

src/FSharpPlus/Control/Foldable.fs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ open System.Runtime.InteropServices
3434
open System.Text
3535
open System.Collections.Generic
3636
open FSharpPlus
37-
open FSharpPlus.Data
3837
open FSharpPlus.Internals
3938
open FSharpPlus.Internals.Prelude
4039

@@ -266,7 +265,6 @@ type Head =
266265
static member Head (x: 'T voption , [<Optional>]_impl: Head ) = x.Value
267266
static member Head (x: Result<_, _> , [<Optional>]_impl: Head ) = Result.get x
268267
static member Head (x: 'T [] , [<Optional>]_impl: Head ) = x.[0]
269-
static member Head (x: NonEmptySeq<'T> , [<Optional>]_impl: Head ) = x.First
270268
static member Head (x: Id<'T> , [<Optional>]_impl: Head ) = x.getValue
271269
static member Head (x: ResizeArray<'T> , [<Optional>]_impl: Head ) = x.[0]
272270
static member Head (x: string , [<Optional>]_impl: Head ) = x.[0]
@@ -281,8 +279,7 @@ type TryHead =
281279
inherit Default1
282280
static member inline TryHead (x , [<Optional>]_impl: Default1) = Seq.tryHead <| ToSeq.Invoke x
283281
static member TryHead (x: 't list , [<Optional>]_impl: TryHead ) = List.tryHead x
284-
static member TryHead (x: 't [] , [<Optional>]_impl: TryHead ) = Array.tryHead x
285-
static member TryHead (x: NonEmptySeq<'T>,[<Optional>]_impl: TryHead) = Some x.First
282+
static member TryHead (x: 't [] , [<Optional>]_impl: TryHead ) = Array.tryHead x
286283
static member TryHead (x: Id<'T> , [<Optional>]_impl: TryHead ) = Some x.getValue
287284
static member TryHead (x: string , [<Optional>]_impl: TryHead ) = String.tryHead x
288285
static member TryHead (x: StringBuilder, [<Optional>]_impl: TryHead ) = if x.Length = 0 then None else Some (x.ToString().[0])
@@ -297,8 +294,7 @@ type TryLast =
297294
inherit Default1
298295
static member inline TryLast (x , [<Optional>]_impl: Default1) = Seq.tryLast <| ToSeq.Invoke x
299296
static member TryLast (x: 't list , [<Optional>]_impl: TryLast) = List.tryLast x
300-
static member TryLast (x: 't [] , [<Optional>]_impl: TryLast) = Array.tryLast x
301-
static member TryLast (x: NonEmptySeq<'T>, [<Optional>]_impl: TryLast) = Some <| Seq.last x
297+
static member TryLast (x: 't [] , [<Optional>]_impl: TryLast) = Array.tryLast x
302298
static member TryLast (x: Id<'T> , [<Optional>]_impl: TryLast ) = Some x.getValue
303299
static member TryLast (x: string , [<Optional>]_impl: TryLast ) = String.tryLast x
304300
static member TryLast (x: StringBuilder , [<Optional>]_impl: TryLast ) = if x.Length = 0 then None else Some (x.ToString().[x.Length - 1])

src/FSharpPlus/Control/Functor.fs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ open FSharpPlus.Internals
1212
open FSharpPlus.Internals.Prelude
1313
open FSharpPlus
1414
open FSharpPlus.Extensions
15-
open FSharpPlus.Data
1615

1716
#if !FABLE_COMPILER
1817

@@ -106,7 +105,6 @@ type Map =
106105
static member Map ((x: StringBuilder , f ), _mthd: Map) = StringBuilder (String.map f (string x))
107106
static member Map ((x: Set<_> , f ), _mthd: Map) = Set.map f x
108107
static member Map ((_: Set2<'T> , _: 'T->'U), _mthd: Map) = Set2<'U>()
109-
static member Map ((x: HashSet<_ > , f ), _mthd: Map) = HashSet.map f x
110108

111109

112110
static member inline Invoke (mapping: 'T->'U) (source: '``Functor<'T>``) : '``Functor<'U>`` =
@@ -131,7 +129,7 @@ type Map with
131129
, f: 'T->'U), [<Optional>]_mthd: Default3) = Apply.InvokeOnInstance (Return.InvokeOnInstance f: '``Applicative<'T->'U>``) x : '``Applicative<'U>``
132130

133131
static member Map ((x: seq<_> , f: 'T->'U), _mthd: Default2) = Seq.map f x : seq<'U>
134-
static member Map ((x: NonEmptySeq<_> , f: 'T->'U), _mthd: Default2) = NonEmptySeq.map f x : NonEmptySeq<'U>
132+
static member Map ((x: NonEmptySeq2<'T> , f: 'T->'U), _mthd: Default2) = failwith "no Map implementation for NonEmptySeq2<'U>" : NonEmptySeq2<'U>
135133
static member Map ((x: IEnumerator<_> , f: 'T->'U), _mthd: Default2) = Enumerator.map f x : IEnumerator<'U>
136134
static member Map ((x: IDictionary<_,_> , f: 'T->'U), _mthd: Default2) = Dict.map f x : IDictionary<'Key,'U>
137135
static member Map ((x: IReadOnlyDictionary<_,_>, f: 'T->'U), _mthd: Default2) = IReadOnlyDictionary.mapValues f x : IReadOnlyDictionary<'Key,_>
@@ -188,8 +186,7 @@ type Unzip =
188186

189187
static member Unzip ((source: ResizeArray<'T * 'U> , _output: ResizeArray<'T> * ResizeArray<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
190188

191-
static member Unzip ((source: seq<'T * 'U> , _output: seq<'T> * seq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
192-
static member Unzip ((source: NonEmptySeq<'T * 'U> , _output: NonEmptySeq<'T> * NonEmptySeq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
189+
static member Unzip ((source: seq<'T * 'U> , _output: seq<'T> * seq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
193190

194191
static member Unzip ((source: IEnumerator<'T * 'U> , _output: IEnumerator<'T> * ResizeArray<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
195192
static member Unzip ((source: IDictionary<'Key, 'T * 'U> , _output: IDictionary<_,'T> * IDictionary<_,'U> ) , _mthd: Unzip ) = Dict.unzip source
@@ -209,8 +206,7 @@ type Unzip =
209206
type Zip =
210207
inherit Default1
211208
static member Zip ((x: IEnumerator<'T> , y: IEnumerator<'U> , _output: IEnumerator<'T*'U> ), _mthd: Zip) = Enumerator.zip x y
212-
static member Zip ((x: seq<'T> , y: seq<'U> , _output: seq<'T*'U> ), _mthd: Zip) = Seq.zip x y
213-
static member Zip ((x: NonEmptySeq<'T> , y: NonEmptySeq<'U> , _output: NonEmptySeq<'T*'U> ), _mthd: Zip) = NonEmptySeq.zip x y
209+
static member Zip ((x: seq<'T> , y: seq<'U> , _output: seq<'T*'U> ), _mthd: Zip) = Seq.zip x y
214210
static member Zip ((x: IDictionary<'K, 'T> , y: IDictionary<'K,'U> , _output: IDictionary<'K,'T*'U> ), _mthd: Zip) = Dict.zip x y
215211
static member Zip ((x: IReadOnlyDictionary<'K, 'T>, y: IReadOnlyDictionary<'K,'U>, _output: IReadOnlyDictionary<'K,'T*'U>), _mthd: Zip) = IReadOnlyDictionary.zip x y
216212
static member Zip ((x: Dictionary<'K, 'T> , y: Dictionary<'K,'U> , _output: Dictionary<'K,'T*'U> ), _mthd: Zip) = Dict.zip x y :?> Dictionary<'K,'T*'U>

src/FSharpPlus/Control/Monad.fs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open System.Threading.Tasks
88
open Microsoft.FSharp.Quotations
99

1010
open FSharpPlus
11-
open FSharpPlus.Data
1211
open FSharpPlus.Internals
1312
open FSharpPlus.Internals.Prelude
1413

@@ -50,13 +49,13 @@ type Bind =
5049
| Some v -> yield k, v
5150
| _ -> () })
5251

53-
static member (>>=) (source: Dictionary<'Key,'T>, f: 'T -> Dictionary<'Key,'U>) =
54-
let dct = Dictionary ()
55-
for KeyValue(k, v) in source do
56-
match (f v).TryGetValue (k) with
57-
| true, v -> dct.Add (k, v)
58-
| _ -> ()
59-
dct
52+
static member (>>=) (source: Dictionary<'Key,'T>, f: 'T -> Dictionary<'Key,'U>) =
53+
let dct = Dictionary ()
54+
for KeyValue(k, v) in source do
55+
match (f v).TryGetValue (k) with
56+
| true, v -> dct.Add (k, v)
57+
| _ -> ()
58+
dct
6059

6160
static member (>>=) (source: IDictionary<'Key,'T>, f: 'T -> IDictionary<'Key,'U>) =
6261
let dct = Dictionary ()
@@ -76,8 +75,6 @@ type Bind =
7675

7776
static member (>>=) (source: ResizeArray<'T>, f: 'T -> ResizeArray<'U>) = ResizeArray (Seq.bind (f >> seq<_>) source) : ResizeArray<'U>
7877

79-
static member (>>=) (source: NonEmptySeq<'T>, f: 'T -> NonEmptySeq<'U>) = NonEmptySeq.collect f source : NonEmptySeq<'U>
80-
8178
#if !FABLE_COMPILER
8279
static member inline Invoke (source: '``Monad<'T>``) (binder: 'T -> '``Monad<'U>``) : '``Monad<'U>`` =
8380
let inline call (_mthd: 'M, input: 'I, _output: 'R, f) = ((^M or ^I or ^R) : (static member (>>=) : _*_ -> _) input, f)
@@ -147,8 +144,6 @@ type Join =
147144
dct :> IReadOnlyDictionary<'Key, 'Value>
148145

149146
static member Join (x: ResizeArray<ResizeArray<'T>> , [<Optional>]_output: ResizeArray<'T> , [<Optional>]_mthd: Join) = ResizeArray (Seq.bind seq<_> x) : ResizeArray<'T>
150-
151-
static member Join (x: NonEmptySeq<NonEmptySeq<'T>> , [<Optional>]_output: NonEmptySeq<'T> , [<Optional>]_mthd: Join) = NonEmptySeq.concat x : NonEmptySeq<'T>
152147

153148
static member inline Invoke (source: '``Monad<Monad<'T>>``) : '``Monad<'T>`` =
154149
let inline call (mthd: 'M, input: 'I, output: 'R) = ((^M or ^I or ^R) : (static member Join : _*_*_ -> _) input, output, mthd)
@@ -169,7 +164,6 @@ type Return =
169164

170165

171166
static member Return (_: seq<'a> , _: Default2) = fun x -> Seq.singleton x : seq<'a>
172-
static member Return (_: NonEmptySeq<'a>, _: Default2) = fun x -> NonEmptySeq.singleton x : NonEmptySeq<'a>
173167
static member Return (_: IEnumerator<'a>, _: Default2) = fun x -> Enumerator.upto None (fun _ -> x) : IEnumerator<'a>
174168
static member inline Return (_: 'R , _: Default1) = fun (x: 'T) -> Return.InvokeOnInstance x : 'R
175169
static member Return (_: Lazy<'a> , _: Return ) = fun x -> Lazy<_>.CreateFromValue x : Lazy<'a>
@@ -212,7 +206,6 @@ type Delay =
212206
static member inline Delay (_mthd: Default1, _: unit-> ^t when ^t : null and ^t : struct , _ ) = ()
213207

214208
static member Delay (_mthd: Default2, x: unit-> _ , _ ) = Seq.delay x : seq<'T>
215-
static member Delay (_mthd: Default2, x: unit-> _ , _ ) = NonEmptySeq.delay x : NonEmptySeq<'T>
216209
static member Delay (_mthd: Default2, x: unit-> 'R -> _ , _ ) = (fun s -> x () s): 'R -> _
217210
static member Delay (_mthd: Delay , x: unit-> _ , _ ) = async.Delay x : Async<'T>
218211
static member Delay (_mthd: Delay , x: unit-> Task<_> , _ ) = x () : Task<'T>
@@ -272,7 +265,6 @@ type TryWith =
272265
static member inline TryWith (_: unit -> ^t when ^t: null and ^t: struct, _ : exn -> 't , _: Default1, _) = ()
273266

274267
static member TryWith (computation: unit -> seq<_> , catchHandler: exn -> seq<_> , _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e))
275-
static member TryWith (computation: unit -> NonEmptySeq<_>, catchHandler: exn -> NonEmptySeq<_>, _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e)) |> NonEmptySeq.unsafeOfSeq
276268
static member TryWith (computation: unit -> 'R -> _ , catchHandler: exn -> 'R -> _ , _: Default2, _) = (fun s -> try (computation ()) s with e -> catchHandler e s) : 'R ->_
277269
static member TryWith (computation: unit -> Async<_> , catchHandler: exn -> Async<_> , _: TryWith , _) = async.TryWith ((computation ()), catchHandler)
278270
#if !FABLE_COMPILER
@@ -297,7 +289,6 @@ type TryFinally =
297289
inherit Default1
298290

299291
static member TryFinally ((computation: unit -> seq<_> , compensation: unit -> unit), _: Default2, _, _) = seq { try for e in computation () do yield e finally compensation () }
300-
static member TryFinally ((computation: unit -> NonEmptySeq<_>, compensation: unit -> unit), _: Default2, _, _) = seq { try for e in computation () do yield e finally compensation () } |> NonEmptySeq.unsafeOfSeq
301292

302293
[<CompilerMessage(MessageTryFinally, CodeTryFinally, IsError = true)>]
303294
static member TryFinally ((_: unit -> 'R -> _ , _: unit -> unit), _: Default2 , _, _defaults: False) = raise Internals.Errors.exnUnreachable
@@ -339,7 +330,6 @@ type Using =
339330
inherit Default1
340331

341332
static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> seq<'U> , _: Using) = seq { try for e in body resource do yield e finally if not (isNull (box resource)) then resource.Dispose () } : seq<'U>
342-
static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> NonEmptySeq<'U>, _: Using) = seq { try for e in body resource do yield e finally if not (isNull (box resource)) then resource.Dispose () } |> NonEmptySeq.unsafeOfSeq : NonEmptySeq<'U>
343333
static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> 'R -> 'U , _: Using ) = (fun s -> try body resource s finally if not (isNull (box resource)) then resource.Dispose ()) : 'R->'U
344334
static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> Async<'U>, _: Using ) = async.Using (resource, body)
345335
#if !FABLE_COMPILER

src/FSharpPlus/Control/Monoid.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open System.Runtime.InteropServices
88
open Microsoft.FSharp.Quotations
99
open System.Threading.Tasks
1010
open FSharpPlus
11-
open FSharpPlus.Data
1211
open FSharpPlus.Internals
1312
open FSharpPlus.Internals.Prelude
1413

@@ -156,7 +155,6 @@ type Plus with
156155
#if !FABLE_COMPILER
157156
static member inline ``+`` (x: IReadOnlyDictionary<'K,'V>, y: IReadOnlyDictionary<'K,'V>, [<Optional>]_mthd: Default3) = IReadOnlyDictionary.unionWith Plus.Invoke x y
158157
#endif
159-
static member inline ``+`` (x: _ NonEmptySeq , y: _ NonEmptySeq , [<Optional>]_mthd: Default3) = NonEmptySeq.append x y
160158

161159

162160

0 commit comments

Comments
 (0)