Skip to content

Commit 5e5531f

Browse files
committed
Merge remote-tracking branch 'origin/master' into compiler/0.12
2 parents 5be916a + 2e8974a commit 5e5531f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

bower.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-foldable-traversable": "#compiler/0.12"
20+
"purescript-foldable-traversable": "#compiler/0.12",
21+
"purescript-prelude": "#compiler/0.12",
22+
"purescript-unfoldable": "#compiler/0.12"
2123
},
2224
"devDependencies": {
2325
"purescript-assert": "#compiler/0.12",

src/Data/NonEmpty.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import Data.Ord (class Ord1)
2525
import Data.Semigroup.Foldable (class Foldable1, foldMap1)
2626
import Data.Traversable (class Traversable, traverse, sequence)
2727
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
28+
import Data.Tuple (uncurry)
29+
import Data.Unfoldable (class Unfoldable, unfoldr)
30+
import Data.Unfoldable1 (class Unfoldable1)
2831

2932
-- | A non-empty container of elements of type a.
3033
-- |
@@ -104,3 +107,6 @@ instance traversableWithIndexNonEmpty
104107
instance foldable1NonEmpty :: Foldable f => Foldable1 (NonEmpty f) where
105108
fold1 = foldMap1 identity
106109
foldMap1 f (a :| fa) = foldl (\s a1 -> s <> f a1) (f a) fa
110+
111+
instance unfoldable1NonEmpty :: Unfoldable f => Unfoldable1 (NonEmpty f) where
112+
unfoldr1 f b = uncurry (:|) $ unfoldr (map f) <$> f b

test/Main.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Data.Foldable (fold, foldl)
66
import Data.Maybe (Maybe(..))
77
import Data.NonEmpty (NonEmpty, (:|), foldl1, oneOf, head, tail, singleton)
88
import Data.Semigroup.Foldable (fold1)
9+
import Data.Unfoldable1 as U1
910
import Effect (Effect)
1011
import Test.Assert (assert)
1112

@@ -24,3 +25,4 @@ main = do
2425
assert $ fold ("Hello" :| [" ", "World"]) == "Hello World"
2526
assert $ oneOf (0 :| Nothing) == oneOf (0 :| Just 1)
2627
assert $ second (1 :| 2 :| [3, 4]) == 2
28+
assert $ U1.range 0 9 == (0 :| [1, 2, 3, 4, 5, 6, 7, 8, 9])

0 commit comments

Comments
 (0)