@@ -14,6 +14,7 @@ main = do
14
14
testIntDivMod
15
15
testIntDegree
16
16
testRecordInstances
17
+ testArrayInstances
17
18
testGenericRep
18
19
19
20
foreign import testNumberShow :: (Number -> String ) -> AlmostEff
@@ -151,3 +152,17 @@ testRecordInstances = do
151
152
assert " Record top" $
152
153
(top :: { a :: Boolean } ).a
153
154
== top
155
+
156
+ testArrayInstances :: AlmostEff
157
+ testArrayInstances = do
158
+ assert " Functor" $ map (_ + 1 ) [1 , 2 , 3 ] == [2 , 3 , 4 ]
159
+ assert " Functor empty" $ map (_ + 1 ) [] == []
160
+ assert " Semigroup" $ append [1 , 2 ] [3 , 4 ] == [1 , 2 , 3 , 4 ]
161
+ assert " Semigroup empty left" $ append [] [3 , 4 ] == [3 , 4 ]
162
+ assert " Semigroup emtpy right" $ append [1 , 2 ] [] == [1 , 2 ]
163
+ assert " Apply" $ apply [(_ + 1 ), (_ * 2 )] [1 , 2 , 3 ] == [2 , 3 , 4 , 2 , 4 , 6 ]
164
+ assert " Apply empty left" $ apply ([] :: Array (Int -> Int )) [1 , 2 , 3 ] == []
165
+ assert " Apply empty right" $ apply [(_ + 1 ), (_ * 2 )] [] == []
166
+ assert " Bind instance" $ bind [1 , 2 , 3 ] (\a -> [a, a]) == [1 , 1 , 2 , 2 , 3 , 3 ]
167
+ assert " Bind instance empty left" $ bind ([] :: Array Int ) (\a -> [a, a]) == []
168
+ assert " Bind instance empty right" $ bind [1 , 2 , 3 ] (\_ -> ([] :: Array Int )) == []
0 commit comments