@@ -71,11 +71,12 @@ import Data.FastVect.FastVect as FV
7171import Data.Foldable (class Foldable )
7272import Data.FoldableWithIndex (class FoldableWithIndex )
7373import Data.FunctorWithIndex (class FunctorWithIndex )
74- import Data.Int.AtLeast (IntAL , fromInt' , toInt )
7574import Data.Int.AtLeast (fromLength ) as IntAL
75+ import Data.Int.AtLeast (IntAL , fromInt' , toInt )
7676import Data.Maybe (Maybe (Nothing, Just), fromJust )
7777import 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
7980import Data.Traversable (class Traversable )
8081import Data.TraversableWithIndex (class TraversableWithIndex )
8182import Partial.Unsafe (unsafePartial )
@@ -107,12 +108,9 @@ derive newtype instance Traversable (ArrayAL n)
107108derive newtype instance TraversableWithIndex Int (ArrayAL n )
108109
109110instance 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
116114
117115instance Apply (ArrayAL n ) where
118116 apply (ArrayAL fab) (ArrayAL a) = ArrayAL (Array .zipWith ($) fab a)
0 commit comments