Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ZipList a = ZipList {
- getZipList :: [a]
Documentation
Lists, but with an Applicative
functor based on zipping.
Examples
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 zipWith
N
>>>
(+) <$> 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]}
ZipList | |
|
Instances
Alternative ZipList Source # | @since base-4.11.0.0 | ||||
Applicative ZipList Source # | f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN) where (\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.01 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
Functor ZipList Source # | @since base-2.01 | ||||
Foldable ZipList Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList 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 # | |||||
Traversable ZipList Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
Generic1 ZipList Source # | |||||
Defined in GHC.Internal.Functor.ZipList
| |||||
Data a => Data (ZipList a) Source # | @since base-4.14.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList 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 # | |||||
Defined in GHC.Internal.Functor.ZipList
| |||||
IsList (ZipList a) Source # | @since base-4.15.0.0 | ||||
Read a => Read (ZipList a) Source # | @since base-4.7.0.0 | ||||
Show a => Show (ZipList a) Source # | @since base-4.7.0.0 | ||||
Eq a => Eq (ZipList a) Source # | @since base-4.7.0.0 | ||||
Ord a => Ord (ZipList a) Source # | @since base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
type Rep1 ZipList Source # | @since base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
type Rep (ZipList a) Source # | @since base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
type Item (ZipList a) Source # | |||||
Defined in GHC.Internal.IsList |