@@ -71,11 +71,12 @@ import Data.FastVect.FastVect as FV
71
71
import Data.Foldable (class Foldable )
72
72
import Data.FoldableWithIndex (class FoldableWithIndex )
73
73
import Data.FunctorWithIndex (class FunctorWithIndex )
74
- import Data.Int.AtLeast (IntAL , fromInt' , toInt )
75
74
import Data.Int.AtLeast (fromLength ) as IntAL
75
+ import Data.Int.AtLeast (IntAL , fromInt' , toInt )
76
76
import Data.Maybe (Maybe (Nothing, Just), fromJust )
77
77
import Data.Reflectable (class Reflectable , reflectType )
78
- import Data.Semigroup.Foldable (class Foldable1 , foldMap1DefaultL )
78
+ import Data.Semigroup.Foldable (class Foldable1 )
79
+ import Data.Semigroup.Foldable as Foldable1
79
80
import Data.Traversable (class Traversable )
80
81
import Data.TraversableWithIndex (class TraversableWithIndex )
81
82
import Partial.Unsafe (unsafePartial )
@@ -107,12 +108,9 @@ derive newtype instance Traversable (ArrayAL n)
107
108
derive newtype instance TraversableWithIndex Int (ArrayAL n )
108
109
109
110
instance Compare n 0 GT => Foldable1 (ArrayAL n ) where
110
- foldMap1 = foldMap1DefaultL
111
- foldr1 = foldr1Impl
112
- foldl1 = foldl1Impl
113
-
114
- foreign import foldr1Impl :: forall n a . (a -> a -> a ) -> ArrayAL n a -> a
115
- foreign import foldl1Impl :: forall n a . (a -> a -> a ) -> ArrayAL n a -> a
111
+ foldMap1 = Foldable1 .foldMap1DefaultL
112
+ foldr1 f xs = Foldable1 .foldr1 f $ toNonEmptyArray xs
113
+ foldl1 f xs = Foldable1 .foldl1 f $ toNonEmptyArray xs
116
114
117
115
instance Apply (ArrayAL n ) where
118
116
apply (ArrayAL fab) (ArrayAL a) = ArrayAL (Array .zipWith ($) fab a)
0 commit comments