@@ -7,15 +7,12 @@ import Data.Eq (class Eq1)
7
7
import Data.Foldable (class Foldable )
8
8
import Data.FoldableWithIndex (class FoldableWithIndex )
9
9
import Data.FunctorWithIndex (class FunctorWithIndex )
10
- import Data.Maybe (Maybe , fromJust , isNothing )
11
10
import Data.Ord (class Ord1 )
12
11
import Data.Semigroup.Foldable (class Foldable1 , foldMap1Default )
13
12
import Data.Semigroup.Traversable (class Traversable1 , sequence1Default )
14
13
import Data.Traversable (class Traversable )
15
14
import Data.TraversableWithIndex (class TraversableWithIndex )
16
- import Data.Tuple (Tuple , fst , snd )
17
15
import Data.Unfoldable1 (class Unfoldable1 )
18
- import Partial.Unsafe (unsafePartial )
19
16
20
17
newtype NonEmptyArray a = NonEmptyArray (Array a )
21
18
@@ -40,9 +37,7 @@ instance foldable1NonEmptyArray :: Foldable1 NonEmptyArray where
40
37
foldMap1 = foldMap1Default
41
38
fold1 = fold1Impl (<>)
42
39
43
- instance unfoldable1NonEmptyArray :: Unfoldable1 NonEmptyArray where
44
- unfoldr1 = unfoldr1Impl isNothing (unsafePartial fromJust) fst snd
45
-
40
+ derive newtype instance unfoldable1NonEmptyArray :: Unfoldable1 NonEmptyArray
46
41
derive newtype instance traversableNonEmptyArray :: Traversable NonEmptyArray
47
42
derive newtype instance traversableWithIndexNonEmptyArray :: TraversableWithIndex Int NonEmptyArray
48
43
@@ -63,16 +58,6 @@ derive newtype instance altNonEmptyArray :: Alt NonEmptyArray
63
58
-- we use FFI here to avoid the unncessary copy created by `tail`
64
59
foreign import fold1Impl :: forall a . (a -> a -> a ) -> NonEmptyArray a -> a
65
60
66
- foreign import unfoldr1Impl
67
- :: forall a b
68
- . (forall x . Maybe x -> Boolean )
69
- -> (forall x . Maybe x -> x )
70
- -> (forall x y . Tuple x y -> x )
71
- -> (forall x y . Tuple x y -> y )
72
- -> (b -> Tuple a (Maybe b ))
73
- -> b
74
- -> NonEmptyArray a
75
-
76
61
foreign import traverse1Impl
77
62
:: forall m a b
78
63
. (forall a' b' . (m (a' -> b' ) -> m a' -> m b' ))
0 commit comments