Skip to content

More concatMap functions (indexed and mutable) #530

Open
@toyboot4e

Description

@toyboot4e

Is it good idea to add the following to Data.Vector.Generic? Thank you.

  1. iconcatMap
iconcatMap :: (Vector v a, Vector v b) => (Int -> a -> v b) -> v a -> v b
{-# INLINE iconcatMap #-}
iconcatMap f = unstream
               . Bundle.concatVectors
               . Bundle.inplace (S.map (uncurry f) . S.indexed) id
               . stream
  1. concatMapM
concatMapM :: (Monad m, Vector v a, Vector v b) => (a -> m (v b)) -> v a -> m (v b)
{-# INLINE concatMapM #-}
concatMapM f = unstreamM
               . MBundle.concatVectors
               . MBundle.mapM f
               . MBundle.fromVector
  1. iconcatMapM
iconcatMapM :: (Monad m, Vector v a, Vector v b) => (Int -> a -> m (v b)) -> v a -> m (v b)
{-# INLINE iconcatMapM #-}
iconcatMapM f = unstreamM
                . MBundle.concatVectors
                . MBundle.mapM (uncurry f)
                . MBundle.indexed
                . MBundle.fromVector

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions