semialign-1.2.0.1: Align and Zip type-classes from the common Semialign ancestor.

Safe Haskell | Trustworthy
Language | Haskell2010

Data.Semialign

Contents

- Classes
- Specialized aligns

Description

Zipping and aligning of functors with non-uniform shapes.

Synopsis

- class Functor f => Semialign f where
  - align :: f a -> f b -> f (These a b)
  - alignWith :: (These a b -> c) -> f a -> f b -> f c
- class Semialign f => Align f where
  - nil :: f a
- class Semialign f => Unalign f where
  - unalign :: f (These a b) -> (f a, f b)
  - unalignWith :: (c -> These a b) -> f c -> (f a, f b)
- class Semialign f => Zip f where
  - zip :: f a -> f b -> f (a, b)
  - zipWith :: (a -> b -> c) -> f a -> f b -> f c
- class Zip f => Repeat f where
  - repeat :: a -> f a
- class Zip f => Unzip f where
  - unzipWith :: (c -> (a, b)) -> f c -> (f a, f b)
  - unzip :: f (a, b) -> (f a, f b)
- unzipDefault :: Functor f => f (a, b) -> (f a, f b)
- salign :: (Semialign f, Semigroup a) => f a -> f a -> f a
- padZip :: Semialign f => f a -> f b -> f (Maybe a, Maybe b)
- padZipWith :: Semialign f => (Maybe a -> Maybe b -> c) -> f a -> f b -> f c
- lpadZip :: [a] -> [b] -> [(Maybe a, b)]
- lpadZipWith :: (Maybe a -> b -> c) -> [a] -> [b] -> [c]
- rpadZip :: [a] -> [b] -> [(a, Maybe b)]
- rpadZipWith :: (a -> Maybe b -> c) -> [a] -> [b] -> [c]
- alignVectorWith :: (Vector v a, Vector v b, Vector v c) => (These a b -> c) -> v a -> v b -> v c

# Classes

class Functor f => Semialign f where #

Functors supporting an `align` operation that takes the union of non-uniform shapes.

Minimal definition: either `align` or `alignWith`.

## Laws

The laws of `align` and `zip` resemble lattice laws. There is a plenty of laws, but they are simply satisfied.

And an addition property if `f` is `Foldable`, which tries to enforce `align`-feel: neither values are duplicated nor lost.

Note: ``join` f x = f x x`

Idempotency

    join align ≡ fmap (join These)

Commutativity

    align x y ≡ swap <$> align y x

Associativity

    align x (align y z) ≡ assoc <$> align (align x y) z

With

    alignWith f a b ≡ f <$> align a b

Functoriality

    align (f <$> x) (g <$> y) ≡ bimap f g <$> align x y

Alignedness, if `f` is `Foldable`

    toList x ≡ toListOf (folded . here) (align x y)
             ≡ mapMaybe justHere (toList (align x y))

And an addition property if `f` is `Foldable`, which tries to enforce `align`-feel: neither values are duplicated nor lost.

    toList x = toListOf (folded . here) (align x y)
             = mapMaybe justHere (toList (align x y))

Minimal complete definition

(align | alignWith)

Methods

align :: f a -> f b -> f (These a b) #

Analogous to ``zip``, combines two structures by taking the union of their shapes and using ``These`` to hold the elements.

alignWith :: (These a b -> c) -> f a -> f b -> f c #

Analogous to ``zipWith``, combines two structures by taking the union of their shapes and combining the elements with the given function.

#### Instances

Instances details

Semialign [] # |
Instance details Defined in Data.Semialign.Internal Methods align :: [a] -> [b] -> [These a b] # alignWith :: (These a b -> c) -> [a] -> [b] -> [c] #
Semialign Maybe # |
Instance details Defined in Data.Semialign.Internal Methods align :: Maybe a -> Maybe b -> Maybe (These a b) # alignWith :: (These a b -> c) -> Maybe a -> Maybe b -> Maybe c #
Semialign Option # |
Instance details Defined in Data.Semialign.Internal Methods align :: Option a -> Option b -> Option (These a b) # alignWith :: (These a b -> c) -> Option a -> Option b -> Option c #
Semialign ZipList # | ``zipWith` = `liftA2`` .
Instance details Defined in Data.Semialign.Internal Methods align :: ZipList a -> ZipList b -> ZipList (These a b) # alignWith :: (These a b -> c) -> ZipList a -> ZipList b -> ZipList c #
Semialign Identity # |
Instance details Defined in Data.Semialign.Internal Methods align :: Identity a -> Identity b -> Identity (These a b) # alignWith :: (These a b -> c) -> Identity a -> Identity b -> Identity c #
Semialign NonEmpty # |
Instance details Defined in Data.Semialign.Internal Methods align :: NonEmpty a -> NonEmpty b -> NonEmpty (These a b) # alignWith :: (These a b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #
Semialign IntMap # |
Instance details Defined in Data.Semialign.Internal Methods align :: IntMap a -> IntMap b -> IntMap (These a b) # alignWith :: (These a b -> c) -> IntMap a -> IntMap b -> IntMap c #
Semialign Tree # |
Instance details Defined in Data.Semialign.Internal Methods align :: Tree a -> Tree b -> Tree (These a b) # alignWith :: (These a b -> c) -> Tree a -> Tree b -> Tree c #
Semialign Seq # |
Instance details Defined in Data.Semialign.Internal Methods align :: Seq a -> Seq b -> Seq (These a b) # alignWith :: (These a b -> c) -> Seq a -> Seq b -> Seq c #
Semialign Vector # |
Instance details Defined in Data.Semialign.Internal Methods align :: Vector a -> Vector b -> Vector (These a b) # alignWith :: (These a b -> c) -> Vector a -> Vector b -> Vector c #
Semialign (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Proxy a -> Proxy b -> Proxy (These a b) # alignWith :: (These a b -> c) -> Proxy a -> Proxy b -> Proxy c #
Ord k => Semialign (Map k) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Map k a -> Map k b -> Map k (These a b) # alignWith :: (These a b -> c) -> Map k a -> Map k b -> Map k c #
(Eq k, Hashable k) => Semialign (HashMap k) # |
Instance details Defined in Data.Semialign.Internal Methods align :: HashMap k a -> HashMap k b -> HashMap k (These a b) # alignWith :: (These a b -> c) -> HashMap k a -> HashMap k b -> HashMap k c #
Monad m => Semialign (Stream m) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Stream m a -> Stream m b -> Stream m (These a b) # alignWith :: (These a b -> c) -> Stream m a -> Stream m b -> Stream m c #
Semialign (Tagged b) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Tagged b a -> Tagged b b0 -> Tagged b (These a b0) # alignWith :: (These a b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c #
Monad m => Semialign (Bundle m v) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Bundle m v a -> Bundle m v b -> Bundle m v (These a b) # alignWith :: (These a b -> c) -> Bundle m v a -> Bundle m v b -> Bundle m v c #
Semialign ((->) e :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods align :: (e -> a) -> (e -> b) -> e -> These a b # alignWith :: (These a b -> c) -> (e -> a) -> (e -> b) -> e -> c #
(Semialign f, Semialign g) => Semialign (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Product f g a -> Product f g b -> Product f g (These a b) # alignWith :: (These a b -> c) -> Product f g a -> Product f g b -> Product f g c #
(Semialign f, Semialign g) => Semialign (Compose f g) # |
Instance details Defined in Data.Semialign.Internal Methods align :: Compose f g a -> Compose f g b -> Compose f g (These a b) # alignWith :: (These a b -> c) -> Compose f g a -> Compose f g b -> Compose f g c #

class Semialign f => Align f where #

A unit of `align`.

## Laws

    (`align` nil) ≡ fmap This
    (nil `align`) ≡ fmap That

Methods

nil :: f a #

An empty structure. ``align``ing with ``nil`` will produce a structure with the same shape and elements as the other input, modulo ``This`` or ``That``.

#### Instances

Instances details

Align [] # |
Instance details Defined in Data.Semialign.Internal Methods nil :: [a] #
Align Maybe # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Maybe a #
Align Option # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Option a #
Align ZipList # |
Instance details Defined in Data.Semialign.Internal Methods nil :: ZipList a #
Align IntMap # |
Instance details Defined in Data.Semialign.Internal Methods nil :: IntMap a #
Align Seq # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Seq a #
Align Vector # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Vector a #
Align (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Proxy a #
Ord k => Align (Map k) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Map k a #
(Eq k, Hashable k) => Align (HashMap k) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: HashMap k a #
Monad m => Align (Stream m) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Stream m a #
Monad m => Align (Bundle m v) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Bundle m v a #
(Align f, Align g) => Align (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Product f g a #
(Align f, Semialign g) => Align (Compose f g) # |
Instance details Defined in Data.Semialign.Internal Methods nil :: Compose f g a #

class Semialign f => Unalign f where #

Alignable functors supporting an "inverse" to `align`: splitting a union shape into its component parts.

## Laws

    uncurry align (unalign xs) ≡ xs
    unalign (align xs ys) ≡ (xs, ys)

## Compatibility note

In version 1 `unalign` was changed to return `(f a, f b)` pair, instead of `(f (Just a), f (Just b))`. Old behaviour can be achieved with if ever needed.

    >>> unzipWith (unalign . Just) [This 'a', That 'b', These 'c' 'd']
    ([Just 'a',Nothing,Just 'c'],[Nothing,Just 'b',Just 'd'])

Minimal complete definition

unalignWith | unalign

Methods

unalign :: f (These a b) -> (f a, f b) #

unalignWith :: (c -> These a b) -> f c -> (f a, f b) #

#### Instances

Instances details

Unalign Maybe # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: Maybe (These a b) -> (Maybe a, Maybe b) # unalignWith :: (c -> These a b) -> Maybe c -> (Maybe a, Maybe b) #
Unalign Option # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: Option (These a b) -> (Option a, Option b) # unalignWith :: (c -> These a b) -> Option c -> (Option a, Option b) #
Unalign IntMap # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: IntMap (These a b) -> (IntMap a, IntMap b) # unalignWith :: (c -> These a b) -> IntMap c -> (IntMap a, IntMap b) #
Unalign (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: Proxy (These a b) -> (Proxy a, Proxy b) # unalignWith :: (c -> These a b) -> Proxy c -> (Proxy a, Proxy b) #
Ord k => Unalign (Map k) # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: Map k (These a b) -> (Map k a, Map k b) # unalignWith :: (c -> These a b) -> Map k c -> (Map k a, Map k b) #
(Eq k, Hashable k) => Unalign (HashMap k) # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: HashMap k (These a b) -> (HashMap k a, HashMap k b) # unalignWith :: (c -> These a b) -> HashMap k c -> (HashMap k a, HashMap k b) #
(Unalign f, Unalign g) => Unalign (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods unalign :: Product f g (These a b) -> (Product f g a, Product f g b) # unalignWith :: (c -> These a b) -> Product f g c -> (Product f g a, Product f g b) #

class Semialign f => Zip f where #

Functors supporting a `zip` operation that takes the intersection of non-uniform shapes.

Minimal definition: either `zip` or `zipWith`.

Idempotency

    join zip   ≡ fmap (join (,))

Commutativity

    zip x y ≡ swap <$> zip y x

Associativity

    zip x (zip y z) ≡ assoc <$> zip (zip x y) z

Absorption

    fst    <$> zip xs (align xs ys) ≡ xs
    toThis <$> align xs (zip xs ys) ≡ This <$> xs
      where
        toThis (This a)    = This a
        toThis (These a _) = This a
        toThis (That b)    = That b

With

    zipWith f a b ≡ f <$> zip a b

Functoriality

    zip (f <$> x) (g <$> y) ≡ bimap f g <$> zip x y

Zippyness

    fmap fst (zip x x) ≡ x
    fmap snd (zip x x) ≡ x
    zip (fmap fst x) (fmap snd x) ≡ x

Distributivity

                       align (zip xs ys) zs ≡ undistrThesePair <$> zip (align xs zs) (align ys zs)
    distrPairThese <$> zip (align xs ys) zs ≡                      align (zip xs zs) (zip ys zs)
                       zip (align xs ys) zs ≡ undistrPairThese <$> align (zip xs zs) (zip ys zs)

Note, the following doesn't hold:

    distrThesePair <$> align (zip xs ys) zs ≢ zip (align xs zs) (align ys zs)

when `xs = []` and `ys = zs = [0]`, then the left hand side is "only" `[(`That` 0, `That` 0)]`, but the right hand side is `[(`That` 0, `These` 0 0)]`.

Minimal complete definition

(zip | zipWith)

Methods

zip :: f a -> f b -> f (a, b) #

Combines two structures by taking the intersection of their shapes and using pair to hold the elements.

zipWith :: (a -> b -> c) -> f a -> f b -> f c #

Combines two structures by taking the intersection of their shapes and combining the elements with the given function.

#### Instances

Instances details

Zip [] # |
Instance details Defined in Data.Semialign.Internal Methods zip :: [a] -> [b] -> [(a, b)] # zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] #
Zip Maybe # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Maybe a -> Maybe b -> Maybe (a, b) # zipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c #
Zip Option # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Option a -> Option b -> Option (a, b) # zipWith :: (a -> b -> c) -> Option a -> Option b -> Option c #
Zip ZipList # |
Instance details Defined in Data.Semialign.Internal Methods zip :: ZipList a -> ZipList b -> ZipList (a, b) # zipWith :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c #
Zip Identity # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Identity a -> Identity b -> Identity (a, b) # zipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c #
Zip NonEmpty # |
Instance details Defined in Data.Semialign.Internal Methods zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) # zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #
Zip IntMap # |
Instance details Defined in Data.Semialign.Internal Methods zip :: IntMap a -> IntMap b -> IntMap (a, b) # zipWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c #
Zip Tree # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Tree a -> Tree b -> Tree (a, b) # zipWith :: (a -> b -> c) -> Tree a -> Tree b -> Tree c #
Zip Seq # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Seq a -> Seq b -> Seq (a, b) # zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c #
Zip Vector # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Vector a -> Vector b -> Vector (a, b) # zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c #
Zip (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Proxy a -> Proxy b -> Proxy (a, b) # zipWith :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #
Ord k => Zip (Map k) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Map k a -> Map k b -> Map k (a, b) # zipWith :: (a -> b -> c) -> Map k a -> Map k b -> Map k c #
(Eq k, Hashable k) => Zip (HashMap k) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: HashMap k a -> HashMap k b -> HashMap k (a, b) # zipWith :: (a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c #
Monad m => Zip (Stream m) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Stream m a -> Stream m b -> Stream m (a, b) # zipWith :: (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c #
Zip (Tagged b) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Tagged b a -> Tagged b b0 -> Tagged b (a, b0) # zipWith :: (a -> b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c #
Monad m => Zip (Bundle m v) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Bundle m v a -> Bundle m v b -> Bundle m v (a, b) # zipWith :: (a -> b -> c) -> Bundle m v a -> Bundle m v b -> Bundle m v c #
Zip ((->) e :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: (e -> a) -> (e -> b) -> e -> (a, b) # zipWith :: (a -> b -> c) -> (e -> a) -> (e -> b) -> e -> c #
(Zip f, Zip g) => Zip (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Product f g a -> Product f g b -> Product f g (a, b) # zipWith :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c #
(Zip f, Zip g) => Zip (Compose f g) # |
Instance details Defined in Data.Semialign.Internal Methods zip :: Compose f g a -> Compose f g b -> Compose f g (a, b) # zipWith :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c #

class Zip f => Repeat f where #

Zippable functors supporting left and right units

Unit

    fst <$> zip xs (repeat y) ≡ xs
    snd <$> zip (repeat x) ys ≡ ys

Methods

repeat :: a -> f a #

A repeat structure.

#### Instances

Instances details

Repeat [] # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> [a] #
Repeat Maybe # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Maybe a #
Repeat Option # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Option a #
Repeat ZipList # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> ZipList a #
Repeat Identity # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Identity a #
Repeat NonEmpty # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> NonEmpty a #
Repeat Tree # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Tree a #
Repeat (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Proxy a #
Repeat (Tagged b) # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Tagged b a #
Repeat ((->) e :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> e -> a #
(Repeat f, Repeat g) => Repeat (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Product f g a #
(Repeat f, Repeat g) => Repeat (Compose f g) # |
Instance details Defined in Data.Semialign.Internal Methods repeat :: a -> Compose f g a #

class Zip f => Unzip f where #

Right inverse of `zip`.

This class is definable for every `Functor`. See `unzipDefault`.

## Laws

    uncurry zip (unzip xs) ≡ xs
    unzip (zip xs xs) ≡ (xs, xs)

Note:

    unzip (zip xs ys) ≢ (xs, _) or (_, ys)

For sequence-like types this holds, but for Map-like it doesn't.

Minimal complete definition

unzipWith | unzip

Methods

unzipWith :: (c -> (a, b)) -> f c -> (f a, f b) #

unzip :: f (a, b) -> (f a, f b) #

#### Instances

Instances details

Unzip [] # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> [c] -> ([a], [b]) # unzip :: [(a, b)] -> ([a], [b]) #
Unzip Maybe # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Maybe c -> (Maybe a, Maybe b) # unzip :: Maybe (a, b) -> (Maybe a, Maybe b) #
Unzip Option # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Option c -> (Option a, Option b) # unzip :: Option (a, b) -> (Option a, Option b) #
Unzip ZipList # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> ZipList c -> (ZipList a, ZipList b) # unzip :: ZipList (a, b) -> (ZipList a, ZipList b) #
Unzip Identity # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Identity c -> (Identity a, Identity b) # unzip :: Identity (a, b) -> (Identity a, Identity b) #
Unzip NonEmpty # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> NonEmpty c -> (NonEmpty a, NonEmpty b) # unzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) #
Unzip IntMap # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> IntMap c -> (IntMap a, IntMap b) # unzip :: IntMap (a, b) -> (IntMap a, IntMap b) #
Unzip Tree # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Tree c -> (Tree a, Tree b) # unzip :: Tree (a, b) -> (Tree a, Tree b) #
Unzip Seq # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Seq c -> (Seq a, Seq b) # unzip :: Seq (a, b) -> (Seq a, Seq b) #
Unzip Vector # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Vector c -> (Vector a, Vector b) # unzip :: Vector (a, b) -> (Vector a, Vector b) #
Unzip (Proxy :: Type -> Type) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Proxy c -> (Proxy a, Proxy b) # unzip :: Proxy (a, b) -> (Proxy a, Proxy b) #
Ord k => Unzip (Map k) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Map k c -> (Map k a, Map k b) # unzip :: Map k (a, b) -> (Map k a, Map k b) #
(Eq k, Hashable k) => Unzip (HashMap k) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> HashMap k c -> (HashMap k a, HashMap k b) # unzip :: HashMap k (a, b) -> (HashMap k a, HashMap k b) #
Unzip (Tagged b) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b0)) -> Tagged b c -> (Tagged b a, Tagged b b0) # unzip :: Tagged b (a, b0) -> (Tagged b a, Tagged b b0) #
(Unzip f, Unzip g) => Unzip (Product f g) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Product f g c -> (Product f g a, Product f g b) # unzip :: Product f g (a, b) -> (Product f g a, Product f g b) #
(Unzip f, Unzip g) => Unzip (Compose f g) # |
Instance details Defined in Data.Semialign.Internal Methods unzipWith :: (c -> (a, b)) -> Compose f g c -> (Compose f g a, Compose f g b) # unzip :: Compose f g (a, b) -> (Compose f g a, Compose f g b) #

unzipDefault :: Functor f => f (a, b) -> (f a, f b) #

# Specialized aligns

salign :: (Semialign f, Semigroup a) => f a -> f a -> f a #

Align two structures and combine with `<>`.

padZip :: Semialign f => f a -> f b -> f (Maybe a, Maybe b) #

Align two structures as in `zip`, but filling in blanks with `Nothing`.

padZipWith :: Semialign f => (Maybe a -> Maybe b -> c) -> f a -> f b -> f c #

Align two structures as in `zipWith`, but filling in blanks with `Nothing`.

lpadZip :: [a] -> [b] -> [(Maybe a, b)] #

Left-padded `zip`.

lpadZipWith :: (Maybe a -> b -> c) -> [a] -> [b] -> [c] #

Left-padded `zipWith`.

rpadZip :: [a] -> [b] -> [(a, Maybe b)] #

Right-padded `zip`.

rpadZipWith :: (a -> Maybe b -> c) -> [a] -> [b] -> [c] #

Right-padded `zipWith`.

alignVectorWith :: (Vector v a, Vector v b, Vector v c) => (These a b -> c) -> v a -> v b -> v c #