@@ -606,6 +606,88 @@ ifoldlColumn f acc c@(UnboxedColumn (column :: VU.Vector d)) = case testEquality
606606 }
607607 )
608608
609+ foldlColumn ::
610+ forall a b .
611+ (Columnable a , Columnable b ) =>
612+ (b -> a -> b ) -> b -> Column -> Either DataFrameException b
613+ foldlColumn f acc c@ (BoxedColumn (column :: VB. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
614+ Just Refl -> pure $ VG. foldl' f acc column
615+ Nothing ->
616+ Left $
617+ TypeMismatchException
618+ ( MkTypeErrorContext
619+ { userType = Right (typeRep @ a )
620+ , expectedType = Right (typeRep @ d )
621+ , callingFunctionName = Just " foldlColumn"
622+ , errorColumnName = Nothing
623+ }
624+ )
625+ foldlColumn f acc c@ (OptionalColumn (column :: VB. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
626+ Just Refl -> pure $ VG. foldl' f acc column
627+ Nothing ->
628+ Left $
629+ TypeMismatchException
630+ ( MkTypeErrorContext
631+ { userType = Right (typeRep @ a )
632+ , expectedType = Right (typeRep @ d )
633+ , callingFunctionName = Just " foldlColumn"
634+ , errorColumnName = Nothing
635+ }
636+ )
637+ foldlColumn f acc c@ (UnboxedColumn (column :: VU. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
638+ Just Refl -> pure $ VG. foldl' f acc column
639+ Nothing ->
640+ Left $
641+ TypeMismatchException
642+ ( MkTypeErrorContext
643+ { userType = Right (typeRep @ a )
644+ , expectedType = Right (typeRep @ d )
645+ , callingFunctionName = Just " foldlColumn"
646+ , errorColumnName = Nothing
647+ }
648+ )
649+
650+ foldl1Column ::
651+ forall a .
652+ (Columnable a ) =>
653+ (a -> a -> a ) -> Column -> Either DataFrameException a
654+ foldl1Column f c@ (BoxedColumn (column :: VB. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
655+ Just Refl -> pure $ VG. foldl1' f column
656+ Nothing ->
657+ Left $
658+ TypeMismatchException
659+ ( MkTypeErrorContext
660+ { userType = Right (typeRep @ a )
661+ , expectedType = Right (typeRep @ d )
662+ , callingFunctionName = Just " foldl1Column"
663+ , errorColumnName = Nothing
664+ }
665+ )
666+ foldl1Column f c@ (OptionalColumn (column :: VB. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
667+ Just Refl -> pure $ VG. foldl1' f column
668+ Nothing ->
669+ Left $
670+ TypeMismatchException
671+ ( MkTypeErrorContext
672+ { userType = Right (typeRep @ a )
673+ , expectedType = Right (typeRep @ d )
674+ , callingFunctionName = Just " foldl1Column"
675+ , errorColumnName = Nothing
676+ }
677+ )
678+ foldl1Column f c@ (UnboxedColumn (column :: VU. Vector d )) = case testEquality (typeRep @ a ) (typeRep @ d ) of
679+ Just Refl -> pure $ VG. foldl1' f column
680+ Nothing ->
681+ Left $
682+ TypeMismatchException
683+ ( MkTypeErrorContext
684+ { userType = Right (typeRep @ a )
685+ , expectedType = Right (typeRep @ d )
686+ , callingFunctionName = Just " foldl1Column"
687+ , errorColumnName = Nothing
688+ }
689+ )
690+
609691headColumn :: forall a . (Columnable a ) => Column -> Either DataFrameException a
610692headColumn (BoxedColumn (col :: VB. Vector b )) = case testEquality (typeRep @ a ) (typeRep @ b ) of
611693 Just Refl ->
0 commit comments