Skip to content

Commit bd6ff91

Browse files
committed
Move wrapped types to test helper file
1 parent bd7074a commit bd6ff91

File tree

2 files changed

+220
-215
lines changed

2 files changed

+220
-215
lines changed

tests/FSharpPlus.Tests/General.fs

Lines changed: 1 addition & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -12,221 +12,7 @@ open Helpers
1212
open FSharpPlus.Math.Applicative
1313
open CSharpLib
1414

15-
type WrappedMapA<'K,'V when 'K : comparison> = WrappedMapA of Map<'K,'V> with
16-
static member ToMap (WrappedMapA m) = m
17-
static member inline TraverseIndexed (WrappedMapA m, f) =
18-
SideEffects.add "Using WrappedMapA's TraverseIndexed"
19-
WrappedMapA <!> (traversei f m : ^__)
20-
module WrappedMapA=
21-
let inline ofList l = Map.ofList l |> WrappedMapA
22-
23-
type WrappedListA<'s> = WrappedListA of 's list with
24-
static member ToSeq (WrappedListA lst) = SideEffects.add "Using WrappedListA's ToSeq"; List.toSeq lst
25-
static member OfSeq lst = WrappedListA (Seq.toList lst)
26-
static member TryItem (i, WrappedListA x) = List.tryItem i x
27-
static member TryParse x =
28-
if x = "[1;2;3]" then Some (WrappedListA [1;2;3])
29-
else None
30-
static member Exists (x, f) =
31-
SideEffects.add "Using WrappedListA's Exists"
32-
let (WrappedListA lst) = x
33-
List.exists f lst
34-
static member Pick (x, f) =
35-
SideEffects.add "Using WrappedListA's Pick"
36-
let (WrappedListA lst) = x
37-
List.pick f lst
38-
static member Min x =
39-
SideEffects.add "Using WrappedListA's Min"
40-
let (WrappedListA lst) = x
41-
List.min lst
42-
static member MaxBy (x, f) =
43-
SideEffects.add "Using WrappedListA's MaxBy"
44-
let (WrappedListA lst) = x
45-
List.maxBy f lst
46-
member this.Length =
47-
SideEffects.add "Using WrappedListA's Length"
48-
let (WrappedListA lst) = this
49-
List.length lst
50-
51-
type WrappedListB<'s> = WrappedListB of 's list with
52-
static member Return x = WrappedListB [x]
53-
static member (+) (WrappedListB l, WrappedListB x) = WrappedListB (l @ x)
54-
static member Zero = WrappedListB List.empty
55-
static member ToSeq (WrappedListB lst) = List.toSeq lst
56-
static member FoldBack (WrappedListB x, f, z) = List.foldBack f x z
57-
58-
type WrappedListB'<'s> = WrappedListB' of 's list with // Same as B but without clean signatures
59-
static member Return (_:WrappedListB'<'a>, _:Return ) = fun (x:'a) -> WrappedListB' [x]
60-
static member (+) (WrappedListB' l, WrappedListB' x) = WrappedListB' (l @ x)
61-
static member Zero (_:WrappedListB'<'a>, _:Zero) = WrappedListB' List.empty
62-
static member ToSeq (WrappedListB' lst) = List.toSeq lst
63-
static member FoldBack (WrappedListB' x, f, z) = List.foldBack f x z
64-
65-
type WrappedListC<'s> = WrappedListC of 's list with
66-
static member (+) (WrappedListC l, WrappedListC x) = WrappedListC (l @ x)
67-
static member Zero = WrappedListC List.empty
68-
static member Sum (lst: seq<WrappedListC<_>>) = Seq.head lst
69-
70-
type WrappedListD<'s> = WrappedListD of 's list with
71-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedListD x) = x in x :> _ seq).GetEnumerator ()
72-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedListD x) = x in x :> _ seq).GetEnumerator () :> Collections.IEnumerator
73-
static member Return (x) = SideEffects.add "Using WrappedListD's Return"; WrappedListD [x]
74-
static member (>>=) ((WrappedListD x):WrappedListD<'T>, f) = SideEffects.add "Using WrappedListD's Bind"; WrappedListD (List.collect (f >> (fun (WrappedListD x) -> x)) x)
75-
static member inline FoldMap (WrappedListD x, f) =
76-
SideEffects.add "Using optimized foldMap"
77-
Seq.fold (fun x y -> x ++ (f y)) zero x
78-
static member Zip (WrappedListD x, WrappedListD y) = SideEffects.add "Using WrappedListD's zip"; WrappedListD (List.zip x y)
79-
static member Exists (x, f) =
80-
SideEffects.add "Using WrappedListD's Exists"
81-
let (WrappedListD lst) = x
82-
List.exists f lst
83-
static member Pick (x, f) =
84-
SideEffects.add "Using WrappedListD's Pick"
85-
let (WrappedListD lst) = x
86-
List.pick f lst
87-
static member Min x =
88-
SideEffects.add "Using WrappedListD's Min"
89-
let (WrappedListD lst) = x
90-
List.min lst
91-
static member MaxBy (x, f) =
92-
SideEffects.add "Using WrappedListD's MaxBy"
93-
let (WrappedListD lst) = x
94-
List.maxBy f lst
95-
static member MapIndexed (WrappedListD x, f) =
96-
SideEffects.add "Using WrappedListD's MapIndexed"
97-
WrappedListD (List.mapi f x)
98-
static member ChooseIndexed (WrappedListD x, f) =
99-
SideEffects.add "Using WrappedListD's ChooseIndexed"
100-
WrappedListD (List.choosei f x)
101-
static member Lift3 (f, WrappedListD x, WrappedListD y, WrappedListD z) =
102-
SideEffects.add "Using WrappedListD's Lift3"
103-
WrappedListD (List.lift3 f x y z)
104-
static member IterateIndexed (WrappedListD x, f) =
105-
SideEffects.add "Using WrappedListD's IterateIndexed"
106-
List.iteri f x
107-
static member inline FoldIndexed (WrappedListD x, f, z) =
108-
SideEffects.add "Using WrappedListD's FoldIndexed"
109-
foldi f z x
110-
static member inline TraverseIndexed (WrappedListD x, f) =
111-
SideEffects.add "Using WrappedListD's TraverseIndexed"
112-
WrappedListD <!> (traversei f x : ^r)
113-
static member FindIndex (WrappedListD x, y) =
114-
SideEffects.add "Using WrappedListD's FindIndex"
115-
findIndex y x
116-
static member FindSliceIndex (WrappedListD x, WrappedListD y) =
117-
SideEffects.add "Using WrappedListD's FindSliceIndex"
118-
findSliceIndex y x
119-
static member FindLastSliceIndex (WrappedListD x, WrappedListD y) =
120-
SideEffects.add "Using WrappedListD's FindLastSliceIndex"
121-
findLastSliceIndex y x
122-
member this.Length =
123-
SideEffects.add "Using WrappedListD's Length"
124-
let (WrappedListD lst) = this
125-
List.length lst
126-
type WrappedListE<'s> = WrappedListE of 's list with
127-
static member Return x = WrappedListE [x]
128-
static member (>>=) (WrappedListE x: WrappedListE<'T>, f) = WrappedListE (List.collect (f >> (fun (WrappedListE x) -> x)) x)
129-
static member get_Empty () = WrappedListE List.empty
130-
static member (<|>) (WrappedListE l, WrappedListE x) = WrappedListE (l @ x)
131-
132-
type WrappedListF<'s> = WrappedListF of 's list with
133-
static member Return x = WrappedListF [x]
134-
static member (>>=) (WrappedListF x: WrappedListF<'T>, f) = WrappedListF (List.collect (f >> (fun (WrappedListF x) -> x)) x)
135-
static member Join (WrappedListF wlst) = SideEffects.add "Join"; WrappedListF wlst >>= id
136-
static member get_Empty () = WrappedListF List.empty
137-
static member (<|>) (WrappedListF l, WrappedListF x) = WrappedListF (l @ x)
138-
139-
type WrappedListG<'s> = WrappedListG of 's list with
140-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedListG x) = x in x :> _ seq).GetEnumerator ()
141-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedListG x) = x in x :> _ seq).GetEnumerator () :> Collections.IEnumerator
142-
static member Return x = WrappedListG [x]
143-
static member (>>=) (WrappedListG x: WrappedListG<'T>, f) = WrappedListG (List.collect (f >> (fun (WrappedListG x) -> x)) x)
144-
static member Join (WrappedListG wlst) = (*SideEffects.add "Join";*) WrappedListG wlst >>= id
145-
static member get_Empty () = WrappedListG List.empty
146-
static member (<|>) (WrappedListG l, WrappedListG x) = WrappedListG (l @ x)
147-
static member Delay (f: unit -> WrappedListG<_>) = SideEffects.add "Using WrappedListG's Delay"; f ()
148-
static member Using (resource, body) = SideEffects.add "Using WrappedListG's Using"; using resource body
149-
150-
type WrappedListH<'s> = WrappedListH of 's list with
151-
static member Map (WrappedListH lst, f) = WrappedListH (List.map f lst)
152-
static member inline Sequence (x: WrappedListH<'``Functor<'T>``>) =
153-
let (WrappedListH lst) = x
154-
let s = sequence lst : '``Functor<List<'T>>``
155-
map WrappedListH s : '``Functor<WrappedListH<'T>>``
156-
157-
type WrappedListI<'s> = WrappedListI of 's list with
158-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedListI x) = x in x :> _ seq).GetEnumerator ()
159-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedListI x) = x in x :> _ seq).GetEnumerator () :> Collections.IEnumerator
160-
static member Return (x) = SideEffects.add "Using WrappedListI's Return"; WrappedListI [x]
161-
static member Sum (lst: seq<WrappedListI<_>>) = Seq.head lst
162-
163-
164-
type WrappedSeqA<'s> = WrappedSeqA of 's seq with
165-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedSeqA x) = x in x).GetEnumerator ()
166-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedSeqA x) = x in x).GetEnumerator () :> Collections.IEnumerator
167-
static member Return x = WrappedSeqA [x]
168-
static member (>>=) (WrappedSeqA x: WrappedSeqA<'T>, f) = WrappedSeqA (Seq.collect (f >> (fun (WrappedSeqA x) -> x)) x)
169-
static member Join (WrappedSeqA wlst) = WrappedSeqA wlst >>= id
170-
static member get_Empty () = WrappedSeqA List.empty
171-
static member (<|>) (WrappedSeqA l, WrappedSeqA x) = WrappedSeqA (Seq.append l x)
172-
static member Delay (f: unit -> WrappedSeqA<_>) =
173-
let run (WrappedSeqA s) = s
174-
WrappedSeqA (Seq.delay (f >> run))
175-
176-
type WrappedSeqB<'s> = WrappedSeqB of 's seq with
177-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedSeqB x) = x in x).GetEnumerator ()
178-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedSeqB x) = x in x).GetEnumerator () :> Collections.IEnumerator
179-
static member Return x = WrappedSeqB [x]
180-
static member (>>=) (WrappedSeqB x: WrappedSeqB<'T>, f) = WrappedSeqB (Seq.collect (f >> (fun (WrappedSeqB x) -> x)) x)
181-
static member Join (WrappedSeqB wlst) = WrappedSeqB wlst >>= id
182-
static member get_Empty () = WrappedSeqB List.empty
183-
static member (<|>) (WrappedSeqB l, WrappedSeqB x) = WrappedSeqB (Seq.append l x)
184-
static member Delay (f: unit -> WrappedSeqB<_>) =
185-
let run (WrappedSeqB s) = s
186-
WrappedSeqB (Seq.delay (f >> run))
187-
static member TryFinally (computation, compensation) =
188-
SideEffects.add "Using WrappedSeqA's TryFinally"
189-
try computation finally compensation ()
190-
static member Using (resource, body) =
191-
SideEffects.add "Using WrappedSeqB's Using"
192-
using resource body
193-
194-
type WrappedSeqC<'s> = WrappedSeqC of 's seq with
195-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedSeqC x) = x in x).GetEnumerator ()
196-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedSeqC x) = x in x).GetEnumerator () :> Collections.IEnumerator
197-
static member Return x = WrappedSeqC [x]
198-
static member (>>=) (WrappedSeqC x: WrappedSeqC<'T>, f) = WrappedSeqC (Seq.collect (f >> (fun (WrappedSeqC x) -> x)) x)
199-
static member Join (WrappedSeqC wlst) = WrappedSeqC wlst >>= id
200-
static member get_Empty () = WrappedSeqC List.empty
201-
static member (<|>) (WrappedSeqC l, WrappedSeqC x) = WrappedSeqC (Seq.append l x)
202-
static member Delay (f: unit -> WrappedSeqC<_>) =
203-
let run (WrappedSeqC s) = s
204-
WrappedSeqC (Seq.delay (f >> run))
205-
static member TryFinally (computation, compensation) =
206-
SideEffects.add "Using WrappedSeqC's TryFinally"
207-
try computation finally compensation ()
208-
209-
type WrappedSeqD<'s> = WrappedSeqD of 's seq with
210-
static member Return x = SideEffects.add "Using WrappedSeqD's Return"; WrappedSeqD (Seq.singleton x)
211-
static member (<*>) (WrappedSeqD f, WrappedSeqD x) = SideEffects.add "Using WrappedSeqD's Apply"; WrappedSeqD (f <*> x)
212-
static member ToList (WrappedSeqD x) = Seq.toList x
213-
static member ChooseIndexed (WrappedSeqD x, f) =
214-
SideEffects.add "Using WrappedSeqD's ChooseIndexed"
215-
WrappedSeqD (Seq.choosei f x)
216-
static member Lift3 (f, WrappedSeqD x, WrappedSeqD y, WrappedSeqD z) =
217-
SideEffects.add "Using WrappedSeqD's Lift3"
218-
WrappedSeqD (Seq.lift3 f x y z)
219-
220-
type WrappedSeqE<'s> = WrappedSeqE of 's seq with
221-
static member Reduce (WrappedSeqE x, reduction) = SideEffects.add "Using WrappedSeqE's Reduce"; Seq.reduce reduction x
222-
static member ToSeq (WrappedSeqE x) = SideEffects.add "Using WrappedSeqE's ToSeq"; x
223-
224-
type WrappedSeqF<'s> = WrappedSeqF of 's seq with
225-
interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedSeqF x) = x in x).GetEnumerator ()
226-
interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedSeqF x) = x in x).GetEnumerator () :> Collections.IEnumerator
227-
static member Return x = SideEffects.add "Using WrappedSeqF's Return"; WrappedSeqF (Seq.singleton x)
228-
static member (<*>) (WrappedSeqF f, WrappedSeqF x) = SideEffects.add "Using WrappedSeqF's Apply"; WrappedSeqF (f <*> x)
229-
static member ToList (WrappedSeqF x) = Seq.toList x
15+
23016

23117
type TestNonEmptyCollection<'a> = private { Singleton: 'a } with
23218
interface NonEmptySeq<'a> with

0 commit comments

Comments
 (0)