Skip to content

Commit e50d73e

Browse files
committed
Simplify some lambdas, remove some unneeded bindings
1 parent a76f4c8 commit e50d73e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/Properties/TypedArray.purs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type TestableArrayF a b n t q =
121121

122122
overAll' :: forall q n. Testable q => Nat n => Int -> Ref Int -> (forall a b t. TestableArrayF a b n t q) -> Effect Unit
123123
overAll' mn count f = do
124-
void (Ref.modify (\x -> x + 1) count)
124+
void (Ref.modify (_ + 1) count)
125125

126126
let chk :: forall a b t. Show t => Eq t => Ord t => Semiring t => Nat b => BytesPerValue a b => TypedArray a t => String -> Proxy (ArrayView a) -> Gen t -> Effect Unit
127127
chk s _ gen = do
@@ -186,7 +186,7 @@ allAreFilledTests count = overAll count allAreFilled
186186
Nothing -> zero
187187
Just y -> y
188188
TA.fill xs x Nothing
189-
let b = TA.all (\y -> y == x) xs
189+
let b = TA.all (_ == x) xs
190190
pure (b <?> "All aren't the filled value")
191191

192192

@@ -234,7 +234,7 @@ filterIsTotalTests count = overAll count filterIsTotal
234234
filterIsTotal (WithOffset _ xs) = do
235235
let pred x = x /= zero
236236
ys = TA.filter pred xs
237-
zs = TA.filter (\x -> not pred x) ys
237+
zs = TA.filter (not pred) ys
238238
azs <- TA.toArray zs
239239
pure $ azs === []
240240

@@ -333,7 +333,7 @@ foldrConsIsToArrayTests count = overAll count foldrConsIsToArray
333333
foldrConsIsToArray :: forall a b t. TestableArrayF a b D0 t Result
334334
foldrConsIsToArray (WithOffset _ xs) = do
335335
axs <- TA.toArray xs
336-
pure $ TA.foldr (\x acc -> Array.cons x acc) [] xs === axs
336+
pure $ TA.foldr Array.cons [] xs === axs
337337

338338

339339
foldlSnocIsToArrayTests :: Ref Int -> Effect Unit
@@ -342,7 +342,7 @@ foldlSnocIsToArrayTests count = overAll count foldlSnocIsToArray
342342
foldlSnocIsToArray :: forall a b t. TestableArrayF a b D0 t Result
343343
foldlSnocIsToArray (WithOffset _ xs) = do
344344
axs <- TA.toArray xs
345-
pure $ TA.foldl (\acc x -> Array.snoc acc x) [] xs === axs
345+
pure $ TA.foldl Array.snoc [] xs === axs
346346

347347

348348
mapIdentityIsIdentityTests :: Ref Int -> Effect Unit
@@ -567,8 +567,7 @@ modifyingOriginalDoesntMutateSlicePartTests count = overAll count modifyingOrigi
567567
where
568568
modifyingOriginalDoesntMutateSlicePart :: forall a b t. TestableArrayF a b D1 t Result
569569
modifyingOriginalDoesntMutateSlicePart (WithOffset os xs) = do
570-
sl <- TA.slice xs (Just (Tuple (Vec.head os) Nothing))
571-
axs <- TA.toArray sl
570+
axs <- TA.toArray =<< TA.slice xs (Just (Tuple (Vec.head os) Nothing))
572571
let o = Vec.head os
573572
if Array.all (eq zero) axs || TA.at xs o == Just zero
574573
then pure Success
@@ -585,8 +584,7 @@ modifyingOriginalDoesntMutateSlicePart2Tests count = overAll count modifyingOrig
585584
where
586585
modifyingOriginalDoesntMutateSlicePart2 :: forall a b t. TestableArrayF a b D1 t Result
587586
modifyingOriginalDoesntMutateSlicePart2 (WithOffset os xs) = do
588-
sl <- TA.slice xs (Just (Tuple (Vec.head os) Nothing))
589-
axs <- TA.toArray sl
587+
axs <- TA.toArray =<< TA.slice xs (Just (Tuple (Vec.head os) Nothing))
590588
let o = Vec.head os
591589
if Array.all (eq zero) axs || TA.at xs o == Just zero
592590
then pure Success
@@ -615,8 +613,7 @@ copyWithinIsSliceTests count = overAll count copyWithinIsSlice
615613
copyWithinIsSlice :: forall a b t. TestableArrayF a b D1 t Result
616614
copyWithinIsSlice (WithOffset os xs) = do
617615
let o = Vec.head os
618-
sl <- TA.slice xs (Just (Tuple o Nothing))
619-
ys <- TA.toArray sl
616+
ys <- TA.toArray =<< TA.slice xs (Just (Tuple o Nothing))
620617
TA.copyWithin xs 0 o Nothing
621618
axs <- TA.toArray xs
622619
zs <- pure $ Array.drop (Array.length ys) axs

0 commit comments

Comments
 (0)