Lists, but with an Applicative functor based on zipping.
Examples
In contrast to the Applicative for GHC.List.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
ZipListgetZipList :: [a]
Instances16Functor, Applicative, Foldable, Traversable, Alternative, Generic1, …
Functor ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListApplicative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListf <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN)where
zipWithNrefers to thezipWithfunction 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"]}Foldable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListTraversable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListGeneric1 ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListIsList (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsListEq a => Eq (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListData a => Data (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListOrd a => Ord (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListRead a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListShow a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListGeneric (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListtype Rep (ZipList a) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList"ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons"ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just"getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))type Rep1 ZipList = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList"ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons"ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just"getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))type Item (ZipList a) = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList