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

Data.Semialign.Internal

Synopsis

Documentation

class Functor f => Semialign f where Source #

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) Source #

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 Source #

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 [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: [a] -> [b] -> [These a b] Source #

alignWith :: (These a b -> c) -> [a] -> [b] -> [c] Source #

Semialign Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Maybe a -> Maybe b -> Maybe (These a b) Source #

alignWith :: (These a b -> c) -> Maybe a -> Maybe b -> Maybe c Source #

Semialign Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Option a -> Option b -> Option (These a b) Source #

alignWith :: (These a b -> c) -> Option a -> Option b -> Option c Source #

Semialign ZipList Source #

zipWith = liftA2 .

Instance details

Defined in Data.Semialign.Internal

Methods

align :: ZipList a -> ZipList b -> ZipList (These a b) Source #

alignWith :: (These a b -> c) -> ZipList a -> ZipList b -> ZipList c Source #

Semialign Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Identity a -> Identity b -> Identity (These a b) Source #

alignWith :: (These a b -> c) -> Identity a -> Identity b -> Identity c Source #

Semialign NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: NonEmpty a -> NonEmpty b -> NonEmpty (These a b) Source #

alignWith :: (These a b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #

Semialign IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: IntMap a -> IntMap b -> IntMap (These a b) Source #

alignWith :: (These a b -> c) -> IntMap a -> IntMap b -> IntMap c Source #

Semialign Tree Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Tree a -> Tree b -> Tree (These a b) Source #

alignWith :: (These a b -> c) -> Tree a -> Tree b -> Tree c Source #

Semialign Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Seq a -> Seq b -> Seq (These a b) Source #

alignWith :: (These a b -> c) -> Seq a -> Seq b -> Seq c Source #

Semialign Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Vector a -> Vector b -> Vector (These a b) Source #

alignWith :: (These a b -> c) -> Vector a -> Vector b -> Vector c Source #

Semialign (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Proxy a -> Proxy b -> Proxy (These a b) Source #

alignWith :: (These a b -> c) -> Proxy a -> Proxy b -> Proxy c Source #

Ord k => Semialign (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Map k a -> Map k b -> Map k (These a b) Source #

alignWith :: (These a b -> c) -> Map k a -> Map k b -> Map k c Source #

(Eq k, Hashable k) => Semialign (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: HashMap k a -> HashMap k b -> HashMap k (These a b) Source #

alignWith :: (These a b -> c) -> HashMap k a -> HashMap k b -> HashMap k c Source #

Monad m => Semialign (Stream m) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Stream m a -> Stream m b -> Stream m (These a b) Source #

alignWith :: (These a b -> c) -> Stream m a -> Stream m b -> Stream m c Source #

Semialign (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Tagged b a -> Tagged b b0 -> Tagged b (These a b0) Source #

alignWith :: (These a b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c Source #

Monad m => Semialign (Bundle m v) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Bundle m v a -> Bundle m v b -> Bundle m v (These a b) Source #

alignWith :: (These a b -> c) -> Bundle m v a -> Bundle m v b -> Bundle m v c Source #

Semialign ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: (e -> a) -> (e -> b) -> e -> These a b Source #

alignWith :: (These a b -> c) -> (e -> a) -> (e -> b) -> e -> c Source #

(Semialign f, Semialign g) => Semialign (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Product f g a -> Product f g b -> Product f g (These a b) Source #

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

(Semialign f, Semialign g) => Semialign (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

align :: Compose f g a -> Compose f g b -> Compose f g (These a b) Source #

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

class Semialign f => Align f where Source #

A unit of align.

Laws

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

Methods

nil :: f a Source #

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

Instances

Instances details
Align [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: [a] Source #

Align Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Maybe a Source #

Align Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Option a Source #

Align ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: ZipList a Source #

Align IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: IntMap a Source #

Align Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Seq a Source #

Align Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Vector a Source #

Align (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Proxy a Source #

Ord k => Align (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Map k a Source #

(Eq k, Hashable k) => Align (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: HashMap k a Source #

Monad m => Align (Stream m) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Stream m a Source #

Monad m => Align (Bundle m v) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Bundle m v a Source #

(Align f, Align g) => Align (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Product f g a Source #

(Align f, Semialign g) => Align (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

nil :: Compose f g a Source #

class Semialign f => Unalign f where Source #

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) Source #

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

Instances

Instances details
Unalign Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: Maybe (These a b) -> (Maybe a, Maybe b) Source #

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

Unalign Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: Option (These a b) -> (Option a, Option b) Source #

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

Unalign IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: IntMap (These a b) -> (IntMap a, IntMap b) Source #

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

Unalign (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: Proxy (These a b) -> (Proxy a, Proxy b) Source #

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

Ord k => Unalign (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: Map k (These a b) -> (Map k a, Map k b) Source #

unalignWith :: (c -> These a b) -> Map k c -> (Map k a, Map k b) Source #

(Eq k, Hashable k) => Unalign (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unalign :: HashMap k (These a b) -> (HashMap k a, HashMap k b) Source #

unalignWith :: (c -> These a b) -> HashMap k c -> (HashMap k a, HashMap k b) Source #

(Unalign f, Unalign g) => Unalign (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

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

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

class Semialign f => Zip f where Source #

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) Source #

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 Source #

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

Instances

Instances details
Zip [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: [a] -> [b] -> [(a, b)] Source #

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source #

Zip Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Maybe a -> Maybe b -> Maybe (a, b) Source #

zipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #

Zip Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Option a -> Option b -> Option (a, b) Source #

zipWith :: (a -> b -> c) -> Option a -> Option b -> Option c Source #

Zip ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: ZipList a -> ZipList b -> ZipList (a, b) Source #

zipWith :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #

Zip Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Identity a -> Identity b -> Identity (a, b) Source #

zipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #

Zip NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) Source #

zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #

Zip IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: IntMap a -> IntMap b -> IntMap (a, b) Source #

zipWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c Source #

Zip Tree Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Tree a -> Tree b -> Tree (a, b) Source #

zipWith :: (a -> b -> c) -> Tree a -> Tree b -> Tree c Source #

Zip Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Seq a -> Seq b -> Seq (a, b) Source #

zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c Source #

Zip Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Vector a -> Vector b -> Vector (a, b) Source #

zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c Source #

Zip (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Proxy a -> Proxy b -> Proxy (a, b) Source #

zipWith :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c Source #

Ord k => Zip (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Map k a -> Map k b -> Map k (a, b) Source #

zipWith :: (a -> b -> c) -> Map k a -> Map k b -> Map k c Source #

(Eq k, Hashable k) => Zip (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: HashMap k a -> HashMap k b -> HashMap k (a, b) Source #

zipWith :: (a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c Source #

Monad m => Zip (Stream m) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Stream m a -> Stream m b -> Stream m (a, b) Source #

zipWith :: (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c Source #

Zip (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Tagged b a -> Tagged b b0 -> Tagged b (a, b0) Source #

zipWith :: (a -> b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c Source #

Monad m => Zip (Bundle m v) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Bundle m v a -> Bundle m v b -> Bundle m v (a, b) Source #

zipWith :: (a -> b -> c) -> Bundle m v a -> Bundle m v b -> Bundle m v c Source #

Zip ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: (e -> a) -> (e -> b) -> e -> (a, b) Source #

zipWith :: (a -> b -> c) -> (e -> a) -> (e -> b) -> e -> c Source #

(Zip f, Zip g) => Zip (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Product f g a -> Product f g b -> Product f g (a, b) Source #

zipWith :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source #

(Zip f, Zip g) => Zip (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

zip :: Compose f g a -> Compose f g b -> Compose f g (a, b) Source #

zipWith :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #

class Zip f => Repeat f where Source #

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 Source #

A repeat structure.

Instances

Instances details
Repeat [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> [a] Source #

Repeat Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Maybe a Source #

Repeat Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Option a Source #

Repeat ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> ZipList a Source #

Repeat Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Identity a Source #

Repeat NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> NonEmpty a Source #

Repeat Tree Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Tree a Source #

Repeat (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Proxy a Source #

Repeat (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Tagged b a Source #

Repeat ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> e -> a Source #

(Repeat f, Repeat g) => Repeat (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Product f g a Source #

(Repeat f, Repeat g) => Repeat (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

repeat :: a -> Compose f g a Source #

class Zip f => Unzip f where Source #

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) Source #

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

Instances

Instances details
Unzip [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> [c] -> ([a], [b]) Source #

unzip :: [(a, b)] -> ([a], [b]) Source #

Unzip Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Maybe c -> (Maybe a, Maybe b) Source #

unzip :: Maybe (a, b) -> (Maybe a, Maybe b) Source #

Unzip Option Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Option c -> (Option a, Option b) Source #

unzip :: Option (a, b) -> (Option a, Option b) Source #

Unzip ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> ZipList c -> (ZipList a, ZipList b) Source #

unzip :: ZipList (a, b) -> (ZipList a, ZipList b) Source #

Unzip Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Identity c -> (Identity a, Identity b) Source #

unzip :: Identity (a, b) -> (Identity a, Identity b) Source #

Unzip NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> NonEmpty c -> (NonEmpty a, NonEmpty b) Source #

unzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) Source #

Unzip IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> IntMap c -> (IntMap a, IntMap b) Source #

unzip :: IntMap (a, b) -> (IntMap a, IntMap b) Source #

Unzip Tree Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Tree c -> (Tree a, Tree b) Source #

unzip :: Tree (a, b) -> (Tree a, Tree b) Source #

Unzip Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Seq c -> (Seq a, Seq b) Source #

unzip :: Seq (a, b) -> (Seq a, Seq b) Source #

Unzip Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Vector c -> (Vector a, Vector b) Source #

unzip :: Vector (a, b) -> (Vector a, Vector b) Source #

Unzip (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Proxy c -> (Proxy a, Proxy b) Source #

unzip :: Proxy (a, b) -> (Proxy a, Proxy b) Source #

Ord k => Unzip (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> Map k c -> (Map k a, Map k b) Source #

unzip :: Map k (a, b) -> (Map k a, Map k b) Source #

(Eq k, Hashable k) => Unzip (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b)) -> HashMap k c -> (HashMap k a, HashMap k b) Source #

unzip :: HashMap k (a, b) -> (HashMap k a, HashMap k b) Source #

Unzip (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

unzipWith :: (c -> (a, b0)) -> Tagged b c -> (Tagged b a, Tagged b b0) Source #

unzip :: Tagged b (a, b0) -> (Tagged b a, Tagged b b0) Source #

(Unzip f, Unzip g) => Unzip (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

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

unzip :: Product f g (a, b) -> (Product f g a, Product f g b) Source #

(Unzip f, Unzip g) => Unzip (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

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

unzip :: Compose f g (a, b) -> (Compose f g a, Compose f g b) Source #

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

class (FunctorWithIndex i f, Semialign f) => SemialignWithIndex i f | f -> i where Source #

Indexed version of Semialign.

Since: 1.2

Minimal complete definition

Nothing

Methods

ialignWith :: (i -> These a b -> c) -> f a -> f b -> f c Source #

Analogous to alignWith, but also provides an index.

Instances

Instances details
SemialignWithIndex Int [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> [a] -> [b] -> [c] Source #

SemialignWithIndex Int ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> ZipList a -> ZipList b -> ZipList c Source #

SemialignWithIndex Int NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #

SemialignWithIndex Int IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> IntMap a -> IntMap b -> IntMap c Source #

SemialignWithIndex Int Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> Seq a -> Seq b -> Seq c Source #

SemialignWithIndex Int Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Int -> These a b -> c) -> Vector a -> Vector b -> Vector c Source #

SemialignWithIndex () Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (() -> These a b -> c) -> Maybe a -> Maybe b -> Maybe c Source #

SemialignWithIndex () Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (() -> These a b -> c) -> Identity a -> Identity b -> Identity c Source #

(Eq k, Hashable k) => SemialignWithIndex k (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (k -> These a b -> c) -> HashMap k a -> HashMap k b -> HashMap k c Source #

Ord k => SemialignWithIndex k (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (k -> These a b -> c) -> Map k a -> Map k b -> Map k c Source #

SemialignWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Void -> These a b -> c) -> Proxy a -> Proxy b -> Proxy c Source #

SemialignWithIndex () (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (() -> These a b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c Source #

SemialignWithIndex e ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (e -> These a b -> c) -> (e -> a) -> (e -> b) -> e -> c Source #

(SemialignWithIndex i f, SemialignWithIndex j g) => SemialignWithIndex (Either i j) (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: (Either i j -> These a b -> c) -> Product f g a -> Product f g b -> Product f g c Source #

(SemialignWithIndex i f, SemialignWithIndex j g) => SemialignWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

ialignWith :: ((i, j) -> These a b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #

class (SemialignWithIndex i f, Zip f) => ZipWithIndex i f | f -> i where Source #

Indexed version of Zip.

Since: 1.2

Minimal complete definition

Nothing

Methods

izipWith :: (i -> a -> b -> c) -> f a -> f b -> f c Source #

Analogous to zipWith, but also provides an index.

Instances

Instances details
ZipWithIndex Int [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> [a] -> [b] -> [c] Source #

ZipWithIndex Int ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #

ZipWithIndex Int NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #

ZipWithIndex Int IntMap Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c Source #

ZipWithIndex Int Seq Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> Seq a -> Seq b -> Seq c Source #

ZipWithIndex Int Vector Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c Source #

ZipWithIndex () Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (() -> a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #

ZipWithIndex () Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (() -> a -> b -> c) -> Identity a -> Identity b -> Identity c Source #

(Eq k, Hashable k) => ZipWithIndex k (HashMap k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (k -> a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c Source #

Ord k => ZipWithIndex k (Map k) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c Source #

ZipWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Void -> a -> b -> c) -> Proxy a -> Proxy b -> Proxy c Source #

ZipWithIndex () (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (() -> a -> b0 -> c) -> Tagged b a -> Tagged b b0 -> Tagged b c Source #

ZipWithIndex e ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (e -> a -> b -> c) -> (e -> a) -> (e -> b) -> e -> c Source #

(ZipWithIndex i f, ZipWithIndex j g) => ZipWithIndex (Either i j) (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: (Either i j -> a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source #

(ZipWithIndex i f, ZipWithIndex j g) => ZipWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

izipWith :: ((i, j) -> a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #

class (ZipWithIndex i f, Repeat f) => RepeatWithIndex i f | f -> i where Source #

Indexed version of Repeat.

Since: 1.2

Minimal complete definition

Nothing

Methods

irepeat :: (i -> a) -> f a Source #

Analogous to repeat, but also provides an index.

This should be the same as tabulate for representable functors.

Instances

Instances details
RepeatWithIndex Int [] Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (Int -> a) -> [a] Source #

RepeatWithIndex Int ZipList Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (Int -> a) -> ZipList a Source #

RepeatWithIndex Int NonEmpty Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (Int -> a) -> NonEmpty a Source #

RepeatWithIndex () Maybe Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (() -> a) -> Maybe a Source #

RepeatWithIndex () Identity Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (() -> a) -> Identity a Source #

RepeatWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (Void -> a) -> Proxy a Source #

RepeatWithIndex () (Tagged b) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (() -> a) -> Tagged b a Source #

RepeatWithIndex e ((->) e :: Type -> Type) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (e -> a) -> e -> a Source #

(RepeatWithIndex i f, RepeatWithIndex j g) => RepeatWithIndex (Either i j) (Product f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: (Either i j -> a) -> Product f g a Source #

(RepeatWithIndex i f, RepeatWithIndex j g) => RepeatWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Data.Semialign.Internal

Methods

irepeat :: ((i, j) -> a) -> Compose f g a Source #

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

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

Align two structures and combine with <>.

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

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 Source #

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

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

Left-padded zipWith.

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

Left-padded zip.

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

Right-padded zipWith.

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

Right-padded zip.