From 2e5fe5e5da2b541669e625dff860783dd8e1c6c2 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 27 Nov 2020 19:40:01 -0800 Subject: [PATCH 01/12] Implement monomorphic version of find that short circuits --- src/Data/Array.purs | 12 +++++++++++- test/Test/Data/Array.purs | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Data/Array.purs b/src/Data/Array.purs index cb1dee91..724b8172 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -54,6 +54,7 @@ module Data.Array , (!!), index , elemIndex , elemLastIndex + , find , findIndex , findLastIndex , insertAt @@ -127,7 +128,7 @@ import Data.Array.NonEmpty.Internal (NonEmptyArray(..)) import Data.Array.ST as STA import Data.Array.ST.Iterator as STAI import Data.Foldable (class Foldable, foldl, foldr, traverse_) -import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, find, findMap, any, all) as Exports +import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, findMap, any, all) as Exports import Data.Maybe (Maybe(..), maybe, isJust, fromJust) import Data.Traversable (scanl, scanr) as Exports import Data.Traversable (sequence, traverse) @@ -418,6 +419,15 @@ elemIndex x = findIndex (_ == x) elemLastIndex :: forall a. Eq a => a -> Array a -> Maybe Int elemLastIndex x = findLastIndex (_ == x) +-- | Find the first element for which a predicate holds. +-- | +-- | ```purescript +-- | findIndex (contains $ Pattern "b") ["a", "bb", "b", "d"] = Just "bb" +-- | findIndex (contains $ Pattern "x") ["a", "bb", "b", "d"] = Nothing +-- | ``` +find :: forall a. (a -> Boolean) -> Array a -> Maybe a +find f xs = unsafePartial (unsafeIndex xs) <$> findIndex f xs + -- | Find the first index for which a predicate holds. -- | -- | ```purescript diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 39ff57a8..388e6555 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -139,6 +139,10 @@ testArray = do assert $ (A.elemLastIndex 1 [1, 2, 1]) == Just 2 assert $ (A.elemLastIndex 4 [1, 2, 1]) == Nothing + log "find should return the first element for which a predicate returns true in an array" + assert $ (A.find (_ /= 1) [1, 2, 1]) == Just 2 + assert $ (A.find (_ == 3) [1, 2, 1]) == Nothing + log "findIndex should return the index of an item that a predicate returns true for in an array" assert $ (A.findIndex (_ /= 1) [1, 2, 1]) == Just 1 assert $ (A.findIndex (_ == 3) [1, 2, 1]) == Nothing From b65647dc4525da6b71d36cda9fb6152e6420a609 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 27 Nov 2020 20:18:21 -0800 Subject: [PATCH 02/12] Implement monomorphic short-circuiting elem and notElem --- src/Data/Array.purs | 12 ++++++++++-- test/Test/Data/Array.purs | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Data/Array.purs b/src/Data/Array.purs index 724b8172..ae6d6330 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -52,6 +52,8 @@ module Data.Array , unsnoc , (!!), index + , elem + , notElem , elemIndex , elemLastIndex , find @@ -128,8 +130,8 @@ import Data.Array.NonEmpty.Internal (NonEmptyArray(..)) import Data.Array.ST as STA import Data.Array.ST.Iterator as STAI import Data.Foldable (class Foldable, foldl, foldr, traverse_) -import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, elem, notElem, findMap, any, all) as Exports -import Data.Maybe (Maybe(..), maybe, isJust, fromJust) +import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, findMap, any, all) as Exports +import Data.Maybe (Maybe(..), maybe, isJust, fromJust, isNothing) import Data.Traversable (scanl, scanr) as Exports import Data.Traversable (sequence, traverse) import Data.Tuple (Tuple(..), fst, snd) @@ -399,6 +401,12 @@ foreign import indexImpl -- | infixl 8 index as !! +elem :: forall a. Eq a => a -> Array a -> Boolean +elem a arr = isJust $ elemIndex a arr + +notElem :: forall a. Eq a => a -> Array a -> Boolean +notElem a arr = isNothing $ elemIndex a arr + -- | Find the index of the first element equal to the specified element. -- | -- | ```purescript diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 388e6555..a81eb0ea 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -131,6 +131,14 @@ testArray = do assert $ [1, 2, 3] !! 6 == Nothing assert $ [1, 2, 3] !! (-1) == Nothing + log "elem should return true if the array contains the given element at least once" + assert $ (A.elem 1 [1, 2, 1]) == true + assert $ (A.elem 4 [1, 2, 1]) == false + + log "notElem should return true if the array does not contain the given element" + assert $ (A.notElem 1 [1, 2, 1]) == false + assert $ (A.notElem 4 [1, 2, 1]) == true + log "elemIndex should return the index of an item that a predicate returns true for in an array" assert $ (A.elemIndex 1 [1, 2, 1]) == Just 0 assert $ (A.elemIndex 4 [1, 2, 1]) == Nothing From 32fab1d47e34e50393d659808ae371d5924aa0ac Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 27 Nov 2020 20:19:56 -0800 Subject: [PATCH 03/12] Implement monomorphic short-circuiting findMap --- src/Data/Array.js | 14 ++++++++++++++ src/Data/Array.purs | 16 +++++++++++++++- test/Test/Data/Array.purs | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Data/Array.js b/src/Data/Array.js index b9792582..39e34a8b 100644 --- a/src/Data/Array.js +++ b/src/Data/Array.js @@ -107,6 +107,20 @@ exports.indexImpl = function (just) { }; }; +exports.findMapImpl = function (nothing) { + return function (isJust) { + return function (f) { + return function (xs) { + for (var i = 0; i < xs.length; i++) { + var result = f(xs[i]); + if (isJust(result)) return result; + } + return nothing; + }; + }; + }; +}; + exports.findIndexImpl = function (just) { return function (nothing) { return function (f) { diff --git a/src/Data/Array.purs b/src/Data/Array.purs index ae6d6330..7bf8d150 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -57,6 +57,7 @@ module Data.Array , elemIndex , elemLastIndex , find + , findMap , findIndex , findLastIndex , insertAt @@ -130,7 +131,7 @@ import Data.Array.NonEmpty.Internal (NonEmptyArray(..)) import Data.Array.ST as STA import Data.Array.ST.Iterator as STAI import Data.Foldable (class Foldable, foldl, foldr, traverse_) -import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, findMap, any, all) as Exports +import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, any, all) as Exports import Data.Maybe (Maybe(..), maybe, isJust, fromJust, isNothing) import Data.Traversable (scanl, scanr) as Exports import Data.Traversable (sequence, traverse) @@ -436,6 +437,19 @@ elemLastIndex x = findLastIndex (_ == x) find :: forall a. (a -> Boolean) -> Array a -> Maybe a find f xs = unsafePartial (unsafeIndex xs) <$> findIndex f xs +-- | Find the first element in a data structure which satisfies +-- | a predicate mapping. +findMap :: forall a b. (a -> Maybe b) -> Array a -> Maybe b +findMap = findMapImpl Nothing isJust + +foreign import findMapImpl + :: forall a b + . (forall c. Maybe c) + -> (forall c. Maybe c -> Boolean) + -> (a -> Maybe b) + -> Array a + -> Maybe b + -- | Find the first index for which a predicate holds. -- | -- | ```purescript diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index a81eb0ea..cc481ccc 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -151,6 +151,10 @@ testArray = do assert $ (A.find (_ /= 1) [1, 2, 1]) == Just 2 assert $ (A.find (_ == 3) [1, 2, 1]) == Nothing + log "findMap should return the mapping of the first element that satisfies the given predicate" + assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 4]) == Just "foo" + assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 1]) == Nothing + log "findIndex should return the index of an item that a predicate returns true for in an array" assert $ (A.findIndex (_ /= 1) [1, 2, 1]) == Just 1 assert $ (A.findIndex (_ == 3) [1, 2, 1]) == Nothing From 466d6ef7bf192d7619c80060be67dbd8084b00e5 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 27 Nov 2020 20:22:24 -0800 Subject: [PATCH 04/12] Implement monomorphic short-circuiting scanl/scanr --- src/Data/Array.js | 28 ++++++++++++++++++++++++++++ src/Data/Array.purs | 28 ++++++++++++++++++++++++++++ test/Test/Data/Array.purs | 8 ++++++++ 3 files changed, 64 insertions(+) diff --git a/src/Data/Array.js b/src/Data/Array.js index 39e34a8b..395fc684 100644 --- a/src/Data/Array.js +++ b/src/Data/Array.js @@ -236,6 +236,34 @@ exports.partition = function (f) { }; }; +exports.scanlImpl = function (f) { + return function (b) { + return function (xs) { + var acc = b; + var out = []; + for (var i = 0; i < xs.length; i++) { + acc = f(acc)(xs[i]); + out.push(acc); + } + return out; + }; + }; +}; + +exports.scanrImpl = function (f) { + return function (b) { + return function (xs) { + var acc = b; + var out = []; + for (var i = xs.length - 1; i >= 0; i--) { + acc = f(xs[i])(acc); + out.push(acc); + } + return out.reverse(); + }; + }; +}; + //------------------------------------------------------------------------------ // Sorting --------------------------------------------------------------------- //------------------------------------------------------------------------------ diff --git a/src/Data/Array.purs b/src/Data/Array.purs index 7bf8d150..72bb3efa 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -78,6 +78,8 @@ module Data.Array , mapMaybe , catMaybes , mapWithIndex + , scanl + , scanr , sort , sortBy @@ -730,6 +732,32 @@ modifyAtIndices :: forall t a. Foldable t => t Int -> (a -> a) -> Array a -> Arr modifyAtIndices is f xs = ST.run (STA.withArray (\res -> traverse_ (\i -> STA.modify i f res) is) xs) +-- | Fold a data structure from the left, keeping all intermediate results +-- | instead of only the final result. Note that the initial value does not +-- | appear in the result (unlike Haskell's `Prelude.scanl`). +-- | +-- | ``` +-- | scanl (+) 0 [1,2,3] = [1,3,6] +-- | scanl (-) 10 [1,2,3] = [9,7,4] +-- | ``` +scanl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b +scanl = scanlImpl + +foreign import scanlImpl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b + +-- | Fold a data structure from the right, keeping all intermediate results +-- | instead of only the final result. Note that the initial value does not +-- | appear in the result (unlike Haskell's `Prelude.scanr`). +-- | +-- | ``` +-- | scanr (+) 0 [1,2,3] = [6,5,3] +-- | scanr (flip (-)) 10 [1,2,3] = [4,5,7] +-- | ``` +scanr :: forall a b. (a -> b -> b) -> b -> Array a -> Array b +scanr = scanrImpl + +foreign import scanrImpl :: forall a b. (a -> b -> b) -> b -> Array a -> Array b + -------------------------------------------------------------------------------- -- Sorting --------------------------------------------------------------------- -------------------------------------------------------------------------------- diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index cc481ccc..3a4da334 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -253,6 +253,14 @@ testArray = do assert $ A.modifyAtIndices [0, 2, 8] not [true, true, true, true] == [false, true, false, true] + log "scanl should return an array that stores the accumulated value at each step" + assert $ A.scanl (+) 0 [1,2,3] == [1, 3, 6] + assert $ A.scanl (-) 10 [1,2,3] == [9, 7, 4] + + log "scanr should return an array that stores the accumulated value at each step" + assert $ A.scanr (+) 0 [1,2,3] == [6,5,3] + assert $ A.scanr (flip (-)) 10 [1,2,3] == [4,5,7] + log "sort should reorder a list into ascending order based on the result of compare" assert $ A.sort [1, 3, 2, 5, 6, 4] == [1, 2, 3, 4, 5, 6] From 5a7e0dddfbdc8a4408310cfb8e53763842a03d3a Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 27 Nov 2020 20:23:44 -0800 Subject: [PATCH 05/12] Add docs to elem and notElem --- src/Data/Array.purs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Data/Array.purs b/src/Data/Array.purs index 72bb3efa..80055c5e 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -404,9 +404,11 @@ foreign import indexImpl -- | infixl 8 index as !! +-- | Returns true if the array has the given element. elem :: forall a. Eq a => a -> Array a -> Boolean elem a arr = isJust $ elemIndex a arr +-- | Returns true if the array does not have the given element. notElem :: forall a. Eq a => a -> Array a -> Boolean notElem a arr = isNothing $ elemIndex a arr From 3052bee89d2c6b789e0ec6c3642d995875373404 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 28 Nov 2020 07:04:24 -0800 Subject: [PATCH 06/12] Remove polymorphic scanl/scanr from exports --- src/Data/Array.purs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Data/Array.purs b/src/Data/Array.purs index 80055c5e..1dbf097f 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -135,7 +135,6 @@ import Data.Array.ST.Iterator as STAI import Data.Foldable (class Foldable, foldl, foldr, traverse_) import Data.Foldable (foldl, foldr, foldMap, fold, intercalate, any, all) as Exports import Data.Maybe (Maybe(..), maybe, isJust, fromJust, isNothing) -import Data.Traversable (scanl, scanr) as Exports import Data.Traversable (sequence, traverse) import Data.Tuple (Tuple(..), fst, snd) import Data.Unfoldable (class Unfoldable, unfoldr) From fe8e0b74fb0bb0822901242b10b48b9dccbc6b1a Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 28 Nov 2020 07:09:13 -0800 Subject: [PATCH 07/12] Create a sized array in scanl/scanr --- src/Data/Array.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Data/Array.js b/src/Data/Array.js index 395fc684..fe977f54 100644 --- a/src/Data/Array.js +++ b/src/Data/Array.js @@ -239,11 +239,12 @@ exports.partition = function (f) { exports.scanlImpl = function (f) { return function (b) { return function (xs) { + var len = xs.length; var acc = b; - var out = []; - for (var i = 0; i < xs.length; i++) { + var out = new Array(len); + for (var i = 0; i < len; i++) { acc = f(acc)(xs[i]); - out.push(acc); + out[i] = acc; } return out; }; @@ -253,13 +254,14 @@ exports.scanlImpl = function (f) { exports.scanrImpl = function (f) { return function (b) { return function (xs) { + var len = xs.length; var acc = b; - var out = []; - for (var i = xs.length - 1; i >= 0; i--) { + var out = new Array(len); + for (var i = len - 1; i >= 0; i--) { acc = f(xs[i])(acc); - out.push(acc); + out[i] = acc; } - return out.reverse(); + return out; }; }; }; From 5d822bc3d5893ec2f00a92942333e8aad3283efe Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Tue, 15 Dec 2020 19:25:13 -0800 Subject: [PATCH 08/12] Add test for cases where more than one elem satisifes predicate --- test/Test/Data/Array.purs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 3a4da334..4e1f1eb9 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -154,6 +154,7 @@ testArray = do log "findMap should return the mapping of the first element that satisfies the given predicate" assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 4]) == Just "foo" assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 1]) == Nothing + assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [4, 1, 4]) == Just "foo" log "findIndex should return the index of an item that a predicate returns true for in an array" assert $ (A.findIndex (_ /= 1) [1, 2, 1]) == Just 1 From 654aaa053ff0d70f3fe1fdd40145d1e9433e0825 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Tue, 15 Dec 2020 19:26:38 -0800 Subject: [PATCH 09/12] Replace scanl/scanr aliases with FFI implementations --- src/Data/Array.js | 4 ++-- src/Data/Array.purs | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Data/Array.js b/src/Data/Array.js index fe977f54..8f0d63d3 100644 --- a/src/Data/Array.js +++ b/src/Data/Array.js @@ -236,7 +236,7 @@ exports.partition = function (f) { }; }; -exports.scanlImpl = function (f) { +exports.scanl = function (f) { return function (b) { return function (xs) { var len = xs.length; @@ -251,7 +251,7 @@ exports.scanlImpl = function (f) { }; }; -exports.scanrImpl = function (f) { +exports.scanr = function (f) { return function (b) { return function (xs) { var len = xs.length; diff --git a/src/Data/Array.purs b/src/Data/Array.purs index 1dbf097f..b208a6fd 100644 --- a/src/Data/Array.purs +++ b/src/Data/Array.purs @@ -741,10 +741,7 @@ modifyAtIndices is f xs = -- | scanl (+) 0 [1,2,3] = [1,3,6] -- | scanl (-) 10 [1,2,3] = [9,7,4] -- | ``` -scanl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b -scanl = scanlImpl - -foreign import scanlImpl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b +foreign import scanl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b -- | Fold a data structure from the right, keeping all intermediate results -- | instead of only the final result. Note that the initial value does not @@ -754,10 +751,7 @@ foreign import scanlImpl :: forall a b. (b -> a -> b) -> b -> Array a -> Array b -- | scanr (+) 0 [1,2,3] = [6,5,3] -- | scanr (flip (-)) 10 [1,2,3] = [4,5,7] -- | ``` -scanr :: forall a b. (a -> b -> b) -> b -> Array a -> Array b -scanr = scanrImpl - -foreign import scanrImpl :: forall a b. (a -> b -> b) -> b -> Array a -> Array b +foreign import scanr :: forall a b. (a -> b -> b) -> b -> Array a -> Array b -------------------------------------------------------------------------------- -- Sorting --------------------------------------------------------------------- From 8148cf3d01e38b3a568b7107410f20090880eff6 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Wed, 16 Dec 2020 18:08:41 -0800 Subject: [PATCH 10/12] Verify findMap: first elem is returned even if later elem satisfies pred --- test/Test/Data/Array.purs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 4e1f1eb9..2d6c43a5 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -152,9 +152,9 @@ testArray = do assert $ (A.find (_ == 3) [1, 2, 1]) == Nothing log "findMap should return the mapping of the first element that satisfies the given predicate" - assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 4]) == Just "foo" - assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [1, 2, 1]) == Nothing - assert $ (A.findMap (\x -> if x > 3 then Just "foo" else Nothing) [4, 1, 4]) == Just "foo" + assert $ (A.findMap (\x -> if x > 3 then Just x else Nothing) [1, 2, 4]) == Just 4 + assert $ (A.findMap (\x -> if x > 3 then Just x else Nothing) [1, 2, 1]) == Nothing + assert $ (A.findMap (\x -> if x > 3 then Just x else Nothing) [4, 1, 5]) == Just 4 log "findIndex should return the index of an item that a predicate returns true for in an array" assert $ (A.findIndex (_ /= 1) [1, 2, 1]) == Just 1 From 58422ad4ac196fb502ddd6f99acd336a36964d72 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Wed, 16 Dec 2020 19:02:43 -0800 Subject: [PATCH 11/12] Verify scanl/r returns same results as Foldable counterpart --- test/Test/Data/Array.purs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 2d6c43a5..428da522 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -6,7 +6,7 @@ import Data.Array ((:), (\\), (!!)) import Data.Array as A import Data.Array.NonEmpty as NEA import Data.Const (Const(..)) -import Data.Foldable (for_, foldMapDefaultR, class Foldable, all, traverse_) +import Data.Foldable (for_, foldMapDefaultR, class Foldable, all, traverse_, scanl, scanr) import Data.Maybe (Maybe(..), isNothing, fromJust) import Data.Tuple (Tuple(..)) import Data.Unfoldable (replicateA) @@ -258,10 +258,18 @@ testArray = do assert $ A.scanl (+) 0 [1,2,3] == [1, 3, 6] assert $ A.scanl (-) 10 [1,2,3] == [9, 7, 4] + log "scanl should return the same results as its Foldable counterpart" + assert $ A.scanl (+) 0 [1,2,3] == scanl (+) 0 [1,2,3] + assert $ A.scanl (-) 10 [1,2,3] == scanl (-) 10 [1,2,3] + log "scanr should return an array that stores the accumulated value at each step" assert $ A.scanr (+) 0 [1,2,3] == [6,5,3] assert $ A.scanr (flip (-)) 10 [1,2,3] == [4,5,7] + log "scanr should return the same results as its Foldable counterpart" + assert $ A.scanr (+) 0 [1,2,3] == scanr (+) 0 [1,2,3] + assert $ A.scanr (flip (-)) 10 [1,2,3] == scanr (flip (-)) 10 [1,2,3] + log "sort should reorder a list into ascending order based on the result of compare" assert $ A.sort [1, 3, 2, 5, 6, 4] == [1, 2, 3, 4, 5, 6] From d27fd6866aed175abf754c6eaa7e5b5b736a2dd7 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Wed, 16 Dec 2020 19:04:17 -0800 Subject: [PATCH 12/12] Import scanl/scanr from correct module --- test/Test/Data/Array.purs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Test/Data/Array.purs b/test/Test/Data/Array.purs index 428da522..7cdbd3b2 100644 --- a/test/Test/Data/Array.purs +++ b/test/Test/Data/Array.purs @@ -6,7 +6,8 @@ import Data.Array ((:), (\\), (!!)) import Data.Array as A import Data.Array.NonEmpty as NEA import Data.Const (Const(..)) -import Data.Foldable (for_, foldMapDefaultR, class Foldable, all, traverse_, scanl, scanr) +import Data.Foldable (for_, foldMapDefaultR, class Foldable, all, traverse_) +import Data.Traversable (scanl, scanr) import Data.Maybe (Maybe(..), isNothing, fromJust) import Data.Tuple (Tuple(..)) import Data.Unfoldable (replicateA)