ghc-internal-9.1201.0: Basic libraries
Safe HaskellNone
LanguageHaskell2010

GHC.Internal.Functor.ZipList

Synopsis

Documentation

newtype ZipList a Source #

Lists, but with an Applicative functor based on zipping.

Examples

Expand

In contrast to the Applicative for List:

>>> (+) <$> [1, 2, 3] <*> [4, 5, 6]
[5,6,7,6,7,8,7,8,9]

The Applicative instance of ZipList applies the operation by pairing up the elements, analogous to zipWithN

>>> (+) <$> ZipList [1, 2, 3] <*> ZipList [4, 5, 6]
ZipList {getZipList = [5,7,9]}
>>> (,,,) <$> ZipList [1, 2] <*> ZipList [3, 4] <*> ZipList [5, 6] <*> ZipList [7, 8]
ZipList {getZipList = [(1,3,5,7),(2,4,6,8)]}
>>> ZipList [(+1), (^2), (/ 2)] <*> ZipList [5, 5, 5]
ZipList {getZipList = [6.0,25.0,2.5]}

Constructors

ZipList 

Fields

Instances

Instances details
Alternative ZipList Source #

Since: base-4.11.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Applicative ZipList Source #
f <$> ZipList xs1 <*> ... <*> ZipList xsN
    = ZipList (zipWithN f xs1 ... xsN)

where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:

(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
    = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
    = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}

Since: base-2.1

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

pure :: a -> ZipList a Source #

(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b Source #

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

(*>) :: ZipList a -> ZipList b -> ZipList b Source #

(<*) :: ZipList a -> ZipList b -> ZipList a Source #

Functor ZipList Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

fmap :: (a -> b) -> ZipList a -> ZipList b Source #

(<$) :: a -> ZipList b -> ZipList a Source #

Foldable ZipList Source #

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

fold :: Monoid m => ZipList m -> m Source #

foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source #

foldr :: (a -> b -> b) -> b -> ZipList a -> b Source #

foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source #

foldl :: (b -> a -> b) -> b -> ZipList a -> b Source #

foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source #

foldr1 :: (a -> a -> a) -> ZipList a -> a Source #

foldl1 :: (a -> a -> a) -> ZipList a -> a Source #

toList :: ZipList a -> [a] Source #

null :: ZipList a -> Bool Source #

length :: ZipList a -> Int Source #

elem :: Eq a => a -> ZipList a -> Bool Source #

maximum :: Ord a => ZipList a -> a Source #

minimum :: Ord a => ZipList a -> a Source #

sum :: Num a => ZipList a -> a Source #

product :: Num a => ZipList a -> a Source #

Traversable ZipList Source #

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

traverse :: Applicative f => (a -> f b) -> ZipList a -> f (ZipList b) Source #

sequenceA :: Applicative f => ZipList (f a) -> f (ZipList a) Source #

mapM :: Monad m => (a -> m b) -> ZipList a -> m (ZipList b) Source #

sequence :: Monad m => ZipList (m a) -> m (ZipList a) Source #

Generic1 ZipList Source # 
Instance details

Defined in GHC.Internal.Functor.ZipList

Associated Types

type Rep1 ZipList

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

type Rep1 ZipList = D1 ('MetaData "ZipList" "GHC.Internal.Functor.ZipList" "ghc-internal" 'True) (C1 ('MetaCons "ZipList" 'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))
Data a => Data (ZipList a) Source #

Since: base-4.14.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZipList a -> c (ZipList a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ZipList a) Source #

toConstr :: ZipList a -> Constr Source #

dataTypeOf :: ZipList a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ZipList a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ZipList a)) Source #

gmapT :: (forall b. Data b => b -> b) -> ZipList a -> ZipList a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ZipList a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ZipList a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source #

Generic (ZipList a) Source # 
Instance details

Defined in GHC.Internal.Functor.ZipList

Associated Types

type Rep (ZipList a)

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

type Rep (ZipList a) = D1 ('MetaData "ZipList" "GHC.Internal.Functor.ZipList" "ghc-internal" 'True) (C1 ('MetaCons "ZipList" 'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))

Methods

from :: ZipList a -> Rep (ZipList a) x Source #

to :: Rep (ZipList a) x -> ZipList a Source #

IsList (ZipList a) Source #

Since: base-4.15.0.0

Instance details

Defined in GHC.Internal.IsList

Associated Types

type Item (ZipList a) 
Instance details

Defined in GHC.Internal.IsList

type Item (ZipList a) = a

Methods

fromList :: [Item (ZipList a)] -> ZipList a Source #

fromListN :: Int -> [Item (ZipList a)] -> ZipList a Source #

toList :: ZipList a -> [Item (ZipList a)] Source #

Read a => Read (ZipList a) Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Show a => Show (ZipList a) Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Eq a => Eq (ZipList a) Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

Methods

(==) :: ZipList a -> ZipList a -> Bool Source #

(/=) :: ZipList a -> ZipList a -> Bool Source #

Ord a => Ord (ZipList a) Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

type Rep1 ZipList Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

type Rep1 ZipList = D1 ('MetaData "ZipList" "GHC.Internal.Functor.ZipList" "ghc-internal" 'True) (C1 ('MetaCons "ZipList" 'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))
type Rep (ZipList a) Source #

Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Functor.ZipList

type Rep (ZipList a) = D1 ('MetaData "ZipList" "GHC.Internal.Functor.ZipList" "ghc-internal" 'True) (C1 ('MetaCons "ZipList" 'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))
type Item (ZipList a) Source # 
Instance details

Defined in GHC.Internal.IsList

type Item (ZipList a) = a