Skip to content

Commit 50cabd1

Browse files
committed
Update build, fix some errors
1 parent 049d92f commit 50cabd1

File tree

4 files changed

+12
-30
lines changed

4 files changed

+12
-30
lines changed

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"purescript-unfoldable": "^1.0.0-rc.1"
2626
},
2727
"devDependencies": {
28+
"purescript-arrays": "^1.0.0-rc.5",
2829
"purescript-assert": "^1.0.0-rc.1",
2930
"purescript-console": "^1.0.0-rc.1"
3031
}

src/Data/List.purs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ module Data.List
1414

1515
, singleton
1616
, (..), range
17-
, replicate
18-
, replicateM
1917
, some
2018
, many
2119

@@ -142,22 +140,6 @@ range start end | start == end = singleton start
142140
go s e step rest | s == e = (Cons s rest)
143141
| otherwise = go (s + step) e step (Cons s rest)
144142

145-
-- | Create a list with repeated instances of a value.
146-
replicate :: forall a. Int -> a -> List a
147-
replicate n value = go n Nil
148-
where
149-
go n rest | n <= 0 = rest
150-
| otherwise = go (n - 1) (Cons value rest)
151-
152-
-- | Perform a monadic action `n` times collecting all of the results.
153-
replicateM :: forall m a. Monad m => Int -> m a -> m (List a)
154-
replicateM n m
155-
| n < one = pure Nil
156-
| otherwise = do
157-
a <- m
158-
as <- replicateM (n - one) m
159-
pure (Cons a as)
160-
161143
-- | Attempt a computation multiple times, requiring at least one success.
162144
-- |
163145
-- | The `Lazy` constraint is used to generate the result lazily, to ensure
@@ -302,7 +284,7 @@ findIndex fn = go 0
302284

303285
-- | Find the last index for which a predicate holds.
304286
findLastIndex :: forall a. (a -> Boolean) -> List a -> Maybe Int
305-
findLastIndex fn xs = ((length xs - 1) -) <$> findIndex fn (reverse xs)
287+
findLastIndex fn xs = ((length xs - 1) - _) <$> findIndex fn (reverse xs)
306288

307289
-- | Insert an element into a list at the specified index, returning a new
308290
-- | list or `Nothing` if the index is out-of-bounds.

src/Data/List/Lazy.purs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ module Data.List.Lazy
1818

1919
, singleton
2020
, (..), range
21-
-- , replicate
22-
-- , replicateM
2321
-- , some
2422
-- , many
2523
, repeat

test/Test/Data/List.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, log)
77

88
import Data.Foldable (foldMap, foldl)
9-
import Data.List (List(Nil, Cons), (..), length, range, foldM, unzip, zip, zipWithA, zipWith, intersectBy, intersect, (\\), deleteBy, delete, unionBy, union, nubBy, nub, groupBy, group', group, span, dropWhile, drop, takeWhile, take, sortBy, sort, catMaybes, mapMaybe, filterM, filter, concat, concatMap, reverse, alterAt, modifyAt, updateAt, deleteAt, insertAt, findLastIndex, findIndex, elemLastIndex, elemIndex, (!!), uncons, init, tail, last, head, insertBy, insert, snoc, null, replicateM, replicate, singleton, fromFoldable, transpose, mapWithIndex, (:))
9+
import Data.List (List(Nil, Cons), (..), length, range, foldM, unzip, zip, zipWithA, zipWith, intersectBy, intersect, (\\), deleteBy, delete, unionBy, union, nubBy, nub, groupBy, group', group, span, dropWhile, drop, takeWhile, take, sortBy, sort, catMaybes, mapMaybe, filterM, filter, concat, concatMap, reverse, alterAt, modifyAt, updateAt, deleteAt, insertAt, findLastIndex, findIndex, elemLastIndex, elemIndex, (!!), uncons, init, tail, last, head, insertBy, insert, snoc, null, singleton, fromFoldable, transpose, mapWithIndex, (:))
1010
import Data.Maybe (Maybe(..), isNothing, fromJust)
1111
import Data.Monoid.Additive (Additive(Additive))
1212
import Data.Tuple (Tuple(..))
13+
import Data.Unfoldable (replicate, replicateA, unfoldr)
1314

1415
import Partial.Unsafe (unsafePartial)
1516

@@ -34,11 +35,11 @@ testList = do
3435
assert $ replicate 0 "foo" == l []
3536
assert $ replicate (-1) "foo" == l []
3637

37-
log "replicateM should perform the monadic action the correct number of times"
38-
assert $ replicateM 3 (Just 1) == Just (l [1, 1, 1])
39-
assert $ replicateM 1 (Just 1) == Just (l [1])
40-
assert $ replicateM 0 (Just 1) == Just (l [])
41-
assert $ replicateM (-1) (Just 1) == Just (l [])
38+
log "replicatA should perform the monadic action the correct number of times"
39+
assert $ replicateA 3 (Just 1) == Just (l [1, 1, 1])
40+
assert $ replicateA 1 (Just 1) == Just (l [1])
41+
assert $ replicateA 0 (Just 1) == Just (l [])
42+
assert $ replicateA (-1) (Just 1) == Just (l [])
4243

4344
-- some
4445
-- many
@@ -295,11 +296,11 @@ testList = do
295296
log "foldMap should be left-to-right"
296297
assert $ foldMap show (range 1 5) == "12345"
297298

298-
log "unfoldr should be stack-safe"
299-
void $ pure $ length $ Data.Unfoldable.replicate 100000 1
299+
log "unfoldable replicate should be stack-safe"
300+
void $ pure $ length $ replicate 100000 1
300301

301302
log "unfoldr should maintain order"
302-
assert $ (1..5) == Data.Unfoldable.unfoldr step 1
303+
assert $ (1..5) == unfoldr step 1
303304

304305
-- log "can find the first 10 primes using lazy lists"
305306
-- let eratos :: L.List Number -> L.List Number

0 commit comments

Comments
 (0)