You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
property["Array obeys the Applicative identity law"]=forAll{(x :ArrayOf<Int>)in
55
+
return(pure(identity)<*> x.getArray)== x.getArray
56
+
}
57
+
58
+
reportProperty["Array obeys the first Applicative composition law"]=forAll{(fl :ArrayOf<ArrowOf<Int8,Int8>>, gl :ArrayOf<ArrowOf<Int8,Int8>>, x :ArrayOf<Int8>)in
59
+
letf= fl.getArray.map({ $0.getArrow })
60
+
letg= gl.getArray.map({ $0.getArrow })
61
+
return(curry(•)<^> f <*> g <*> x.getArray)==(f <*>(g <*> x.getArray))
62
+
}
63
+
64
+
reportProperty["Array obeys the second Applicative composition law"]=forAll{(fl :ArrayOf<ArrowOf<Int8,Int8>>, gl :ArrayOf<ArrowOf<Int8,Int8>>, x :ArrayOf<Int8>)in
65
+
letf= fl.getArray.map({ $0.getArrow })
66
+
letg= gl.getArray.map({ $0.getArrow })
67
+
return(pure(curry(•))<*> f <*> g <*> x.getArray)==(f <*>(g <*> x.getArray))
68
+
}
69
+
70
+
property["Array obeys the Monad left identity law"]=forAll{(a :Int, fa :ArrowOf<Int,ArrayOf<Int>>)in
71
+
letf={ $0.getArray }• fa.getArrow
72
+
return(pure(a)>>- f)==f(a)
73
+
}
74
+
75
+
property["Array obeys the Monad right identity law"]=forAll{(m :ArrayOf<Int>)in
76
+
return(m.getArray >>- pure)== m.getArray
77
+
}
78
+
79
+
property["Array obeys the Monad associativity law"]=forAll{(fa :ArrowOf<Int,ArrayOf<Int>>, ga :ArrowOf<Int,ArrayOf<Int>>, m :ArrayOf<Int>)in
80
+
letf={ $0.getArray }• fa.getArrow
81
+
letg={ $0.getArray }• ga.getArrow
82
+
return((m.getArray >>- f)>>- g)==(m.getArray >>-{ x inf(x)>>- g })
reportProperty["List obeys the first Applicative composition law"]=forAll{(fl :ListOf<ArrowOf<Int8,Int8>>, gl :ListOf<ArrowOf<Int8,Int8>>, x :ListOf<Int8>)in
92
-
letf= fl.getList.fmap({ $0.getArrow })
93
-
letg= gl.getList.fmap({ $0.getArrow })
94
-
return(curry(•)<^> f <*> g <*> x.getList)==(f <*>(g <*> x.getList))
95
-
}
96
-
97
-
reportProperty["List obeys the second Applicative composition law"]=forAll{(fl :ListOf<ArrowOf<Int8,Int8>>, gl :ListOf<ArrowOf<Int8,Int8>>, x :ListOf<Int8>)in
98
-
letf= fl.getList.fmap({ $0.getArrow })
99
-
letg= gl.getList.fmap({ $0.getArrow })
100
-
return(List.pure(curry(•))<*> f <*> g <*> x.getList)==(f <*>(g <*> x.getList))
101
-
}
88
+
// Swift unroller can't handle our scale.
89
+
// property["List obeys the first Applicative composition law"] = forAll { (fl : ListOf<ArrowOf<Int8, Int8>>, gl : ListOf<ArrowOf<Int8, Int8>>, x : ListOf<Int8>) in
90
+
// let f = fl.getList.fmap({ $0.getArrow })
91
+
// let g = gl.getList.fmap({ $0.getArrow })
92
+
// return (curry(•) <^> f <*> g <*> x.getList) == (f <*> (g <*> x.getList))
93
+
// }
94
+
//
95
+
// property["List obeys the second Applicative composition law"] = forAll { (fl : ListOf<ArrowOf<Int8, Int8>>, gl : ListOf<ArrowOf<Int8, Int8>>, x : ListOf<Int8>) in
96
+
// let f = fl.getList.fmap({ $0.getArrow })
97
+
// let g = gl.getList.fmap({ $0.getArrow })
98
+
// return (List.pure(curry(•)) <*> f <*> g <*> x.getList) == (f <*> (g <*> x.getList))
99
+
// }
102
100
103
101
property["List obeys the Monoidal left identity law"]=forAll{(x :ListOf<Int8>)in
104
102
return(x.getList + List())== x.getList
@@ -109,18 +107,14 @@ class ListSpec : XCTestCase {
109
107
}
110
108
111
109
property["List can cycle into an infinite list"]=forAll{(x :ListOf<Int8>)in
112
-
ifx.getList.isEmpty(){
113
-
returnrejected()
114
-
}
110
+
return !x.getList.isEmpty()==>{
111
+
letfinite= x.getList
112
+
letcycle= finite.cycle()
115
113
116
-
letfinite= x.getList
117
-
letcycle= finite.cycle()
118
-
fori:UIntin(0...100){
119
-
ifcycle[i]!=finite[(i % finite.length())]{
120
-
returnfalse
114
+
returnforAll{(n :Positive<Int>)in
115
+
return(0...UInt(n.getPositive)).map({ i incycle[i]==finite[(i % finite.length())]}).filter(==false).isEmpty
reportProperty["Maybe obeys the first Applicative composition law"]=forAll{(fl :MaybeOf<ArrowOf<Int8,Int8>>, gl :MaybeOf<ArrowOf<Int8,Int8>>, x :MaybeOf<Int8>)in
85
+
property["Maybe obeys the first Applicative composition law"]=forAll{(fl :MaybeOf<ArrowOf<Int8,Int8>>, gl :MaybeOf<ArrowOf<Int8,Int8>>, x :MaybeOf<Int8>)in
89
86
letf= fl.getMaybe.fmap({ $0.getArrow })
90
87
letg= gl.getMaybe.fmap({ $0.getArrow })
91
88
return(curry(•)<^> f <*> g <*> x.getMaybe)==(f <*>(g <*> x.getMaybe))
92
89
}
93
90
94
-
reportProperty["Maybe obeys the second Applicative composition law"]=forAll{(fl :MaybeOf<ArrowOf<Int8,Int8>>, gl :MaybeOf<ArrowOf<Int8,Int8>>, x :MaybeOf<Int8>)in
91
+
property["Maybe obeys the second Applicative composition law"]=forAll{(fl :MaybeOf<ArrowOf<Int8,Int8>>, gl :MaybeOf<ArrowOf<Int8,Int8>>, x :MaybeOf<Int8>)in
95
92
letf= fl.getMaybe.fmap({ $0.getArrow })
96
93
letg= gl.getMaybe.fmap({ $0.getArrow })
97
94
return(Maybe.pure(curry(•))<*> f <*> g <*> x.getMaybe)==(f <*>(g <*> x.getMaybe))
98
95
}
96
+
97
+
property["Maybe obeys the Monad left identity law"]=forAll{(a :Int, fa :ArrowOf<Int,MaybeOf<Int>>)in
98
+
letf={ $0.getMaybe }• fa.getArrow
99
+
return(Maybe.pure(a)>>- f)==f(a)
100
+
}
101
+
102
+
property["Maybe obeys the Monad right identity law"]=forAll{(m :MaybeOf<Int>)in
103
+
return(m.getMaybe >>-Maybe.pure)== m.getMaybe
104
+
}
105
+
106
+
property["Maybe obeys the Monad associativity law"]=forAll{(fa :ArrowOf<Int,MaybeOf<Int>>, ga :ArrowOf<Int,MaybeOf<Int>>, m :MaybeOf<Int>)in
107
+
letf={ $0.getMaybe }• fa.getArrow
108
+
letg={ $0.getMaybe }• ga.getArrow
109
+
return((m.getMaybe >>- f)>>- g)==(m.getMaybe >>-{ x inf(x)>>- g })
property["Optional obeys the first Applicative composition law"]=forAll{(fl :OptionalOf<ArrowOf<Int8,Int8>>, gl :OptionalOf<ArrowOf<Int8,Int8>>, x :OptionalOf<Int8>)in
67
+
letf= fl.getOptional.map({ $0.getArrow })
68
+
letg= gl.getOptional.map({ $0.getArrow })
69
+
70
+
letl=(curry(•)<^> f <*> g <*> x.getOptional)
71
+
letr=(f <*>(g <*> x.getOptional))
72
+
return l == r
73
+
}
74
+
75
+
property["Optional obeys the second Applicative composition law"]=forAll{(fl :OptionalOf<ArrowOf<Int8,Int8>>, gl :OptionalOf<ArrowOf<Int8,Int8>>, x :OptionalOf<Int8>)in
76
+
letf= fl.getOptional.map({ $0.getArrow })
77
+
letg= gl.getOptional.map({ $0.getArrow })
73
78
79
+
letl=(pure(curry(•))<*> f <*> g <*> x.getOptional)
80
+
letr=(f <*>(g <*> x.getOptional))
81
+
return l == r
82
+
}
83
+
84
+
property["Optional obeys the Monad left identity law"]=forAll{(a :Int, fa :ArrowOf<Int,OptionalOf<Int>>)in
85
+
letf={ $0.getOptional }• fa.getArrow
86
+
return(pure(a)>>- f)==f(a)
87
+
}
88
+
89
+
property["Optional obeys the Monad right identity law"]=forAll{(m :OptionalOf<Int>)in
90
+
return(m.getOptional >>- pure)== m.getOptional
91
+
}
92
+
93
+
property["Optional obeys the Monad associativity law"]=forAll{(fa :ArrowOf<Int,OptionalOf<Int>>, ga :ArrowOf<Int,OptionalOf<Int>>, m :OptionalOf<Int>)in
94
+
letf={ $0.getOptional }• fa.getArrow
95
+
letg={ $0.getOptional }• ga.getArrow
96
+
return((m.getOptional >>- f)>>- g)==(m.getOptional >>-{ x inf(x)>>- g })
property["String obeys the Applicative identity law"]=forAll{(x :String)in
53
53
return(pure(identity)<*> x)== x
54
54
}
55
55
56
-
reportProperty["String obeys the first Applicative composition law"]=forAll{(fl :ArrayOf<ArrowOf<Character,Character>>, gl :ArrayOf<ArrowOf<Character,Character>>, x :String)in
57
-
letf= fl.getArray.map({ $0.getArrow })
58
-
letg= gl.getArray.map({ $0.getArrow })
59
-
return(curry(•)<^> f <*> g <*> x)==(f <*>(g <*> x))
60
-
}
61
-
62
-
reportProperty["String obeys the second Applicative composition law"]=forAll{(fl :ArrayOf<ArrowOf<Character,Character>>, gl :ArrayOf<ArrowOf<Character,Character>>, x :String)in
63
-
letf= fl.getArray.map({ $0.getArrow })
64
-
letg= gl.getArray.map({ $0.getArrow })
65
-
return(pure(curry(•))<*> f <*> g <*> x)==(f <*>(g <*> x))
66
-
}
56
+
// Swift unroller can't handle our scale.
57
+
// property["String obeys the first Applicative composition law"] = forAll { (fl : ArrayOf<ArrowOf<Character, Character>>, gl : ArrayOf<ArrowOf<Character, Character>>, x : String) in
58
+
// let f = fl.getArray.map({ $0.getArrow })
59
+
// let g = gl.getArray.map({ $0.getArrow })
60
+
// return (curry(•) <^> f <*> g <*> x) == (f <*> (g <*> x))
61
+
// }
62
+
//
63
+
// property["String obeys the second Applicative composition law"] = forAll { (fl : ArrayOf<ArrowOf<Character, Character>>, gl : ArrayOf<ArrowOf<Character, Character>>, x : String) in
64
+
// let f = fl.getArray.map({ $0.getArrow })
65
+
// let g = gl.getArray.map({ $0.getArrow })
66
+
// return (pure(curry(•)) <*> f <*> g <*> x) == (f <*> (g <*> x))
67
+
// }
67
68
68
69
property["String obeys the Monoidal left identity law"]=forAll{(x :String)in
69
70
return(x + String.mzero)== x
@@ -90,7 +91,7 @@ class StringExtSpec : XCTestCase {
0 commit comments