{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module List.Transformer
(
ListT(..)
, runListT
, fold
, foldM
, select
, unfold
, take
, drop
, dropWhile
, takeWhile
, zip
, Step(..)
, ZipListT(..)
, MonadTrans(..)
, MonadIO(..)
, Alternative(..)
, MFunctor (..)
) where
#if MIN_VERSION_base(4,8,0)
import Control.Applicative (Alternative(..), liftA2)
#else
import Control.Applicative (Applicative(..), Alternative(..), liftA2)
import Data.Foldable (Foldable)
import Data.Functor ((<$))
import Data.Monoid (Monoid(..))
import Data.Traversable (Traversable)
#endif
import Control.Monad (MonadPlus(..))
import Control.Monad.Error.Class (MonadError(..))
#if MIN_VERSION_base(4,9,0) && !(MIN_VERSION_base(4,13,0))
import Control.Monad.Fail (MonadFail(..))
#endif
import Control.Monad.Morph (MFunctor (..))
import Control.Monad.State.Class (MonadState(..))
import Control.Monad.Reader.Class (MonadReader(..))
import Control.Monad.Trans (MonadTrans(..), MonadIO(..))
import Data.Semigroup (Semigroup(..))
import Prelude hiding (drop, dropWhile, pred, take, takeWhile, zip)
import qualified Data.Foldable
newtype ListT m a = ListT { forall (m :: * -> *) a. ListT m a -> m (Step m a)
next :: m (Step m a) }
deriving (forall a. ListT m a -> Bool
forall m a. Monoid m => (a -> m) -> ListT m a -> m
forall a b. (a -> b -> b) -> b -> ListT m a -> b
forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ListT m a -> Bool
forall (m :: * -> *) a. (Foldable m, Num a) => ListT m a -> a
forall (m :: * -> *) a. (Foldable m, Ord a) => ListT m a -> a
forall (m :: * -> *) m. (Foldable m, Monoid m) => ListT m m -> m
forall (m :: * -> *) a. Foldable m => ListT m a -> Bool
forall (m :: * -> *) a. Foldable m => ListT m a -> Int
forall (m :: * -> *) a. Foldable m => ListT m a -> [a]
forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ListT m a -> a
forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ListT m a -> m
forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ListT m a -> b
forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ListT m a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ListT m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => ListT m a -> a
sum :: forall a. Num a => ListT m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => ListT m a -> a
minimum :: forall a. Ord a => ListT m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ListT m a -> a
maximum :: forall a. Ord a => ListT m a -> a
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ListT m a -> a
elem :: forall a. Eq a => a -> ListT m a -> Bool
$celem :: forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ListT m a -> Bool
length :: forall a. ListT m a -> Int
$clength :: forall (m :: * -> *) a. Foldable m => ListT m a -> Int
null :: forall a. ListT m a -> Bool
$cnull :: forall (m :: * -> *) a. Foldable m => ListT m a -> Bool
toList :: forall a. ListT m a -> [a]
$ctoList :: forall (m :: * -> *) a. Foldable m => ListT m a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ListT m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ListT m a -> a
foldr1 :: forall a. (a -> a -> a) -> ListT m a -> a
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ListT m a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ListT m a -> b
$cfoldl' :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ListT m a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ListT m a -> b
$cfoldl :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ListT m a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ListT m a -> b
$cfoldr' :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ListT m a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ListT m a -> b
$cfoldr :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ListT m a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ListT m a -> m
$cfoldMap' :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ListT m a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ListT m a -> m
$cfoldMap :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ListT m a -> m
fold :: forall m. Monoid m => ListT m m -> m
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => ListT m m -> m
Foldable, forall {m :: * -> *}. (Monad m, Traversable m) => Functor (ListT m)
forall {m :: * -> *}.
(Monad m, Traversable m) =>
Foldable (ListT m)
forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ListT m (m a) -> m (ListT m a)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ListT m (f a) -> f (ListT m a)
forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ListT m a -> m (ListT m b)
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> ListT m a -> f (ListT m b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListT m a -> f (ListT m b)
sequence :: forall (m :: * -> *) a. Monad m => ListT m (m a) -> m (ListT m a)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ListT m (m a) -> m (ListT m a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ListT m a -> m (ListT m b)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ListT m a -> m (ListT m b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ListT m (f a) -> f (ListT m a)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ListT m (f a) -> f (ListT m a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListT m a -> f (ListT m b)
$ctraverse :: forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> ListT m a -> f (ListT m b)
Traversable)
instance MonadTrans ListT where
lift :: forall (m :: * -> *) a. Monad m => m a -> ListT m a
lift m a
m = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
a
x <- m a
m
forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x forall (f :: * -> *) a. Alternative f => f a
empty) )
instance Monad m => Functor (ListT m) where
fmap :: forall a b. (a -> b) -> ListT m a -> ListT m b
fmap a -> b
k (ListT m (Step m a)
m) = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
forall (m :: * -> *) a. Monad m => a -> m a
return (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
k Step m a
s) )
instance Monad m => Applicative (ListT m) where
pure :: forall a. a -> ListT m a
pure a
x = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x forall (f :: * -> *) a. Alternative f => f a
empty))
ListT m (Step m (a -> b))
m <*> :: forall a b. ListT m (a -> b) -> ListT m a -> ListT m b
<*> ListT m a
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m (a -> b)
s <- m (Step m (a -> b))
m
case Step m (a -> b)
s of
Step m (a -> b)
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil
Cons a -> b
f ListT m (a -> b)
l' -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ListT m a
l forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m (a -> b)
l' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ListT m a
l)) )
ListT m (Step m a)
m *> :: forall a b. ListT m a -> ListT m b -> ListT m b
*> ListT m b
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil
Cons a
_ ListT m a
l' -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (ListT m b
l forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ListT m b
l)) )
ListT m (Step m a)
m <* :: forall a b. ListT m a -> ListT m b -> ListT m a
<* ListT m b
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l' -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ((a
x forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ListT m b
l) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ListT m b
l)) )
instance Monad m => Monad (ListT m) where
return :: forall a. a -> ListT m a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
ListT m (Step m a)
m >>= :: forall a b. ListT m a -> (a -> ListT m b) -> ListT m b
>>= a -> ListT m b
k = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l' -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (a -> ListT m b
k a
x forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> ListT m b
k)) )
#if !(MIN_VERSION_base(4,13,0))
fail _ = mzero
#endif
instance Monad m => Alternative (ListT m) where
empty :: forall a. ListT m a
empty = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil)
ListT m (Step m a)
m <|> :: forall a. ListT m a -> ListT m a -> ListT m a
<|> ListT m a
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
Cons a
x ListT m a
l' -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (ListT m a
l' forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ListT m a
l)) )
instance Monad m => MonadPlus (ListT m) where
mzero :: forall a. ListT m a
mzero = forall (f :: * -> *) a. Alternative f => f a
empty
mplus :: forall a. ListT m a -> ListT m a -> ListT m a
mplus = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
#if MIN_VERSION_base(4,9,0)
instance Monad m => MonadFail (ListT m) where
fail :: forall a. String -> ListT m a
fail String
_ = forall (m :: * -> *) a. MonadPlus m => m a
mzero
#endif
instance (Monad m, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (ListT m a) where
<> :: ListT m a -> ListT m a -> ListT m a
(<>) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Semigroup a => a -> a -> a
(<>)
instance (Monad m, Data.Semigroup.Semigroup a, Monoid a) => Monoid (ListT m a) where
mempty :: ListT m a
mempty = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty
#if !(MIN_VERSION_base(4,11,0))
mappend = (<>)
#endif
instance MonadIO m => MonadIO (ListT m) where
liftIO :: forall a. IO a -> ListT m a
liftIO IO a
m = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO a
m)
instance MonadError e m => MonadError e (ListT m) where
throwError :: forall a. e -> ListT m a
throwError e
e = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError e
e)
catchError :: forall a. ListT m a -> (e -> ListT m a) -> ListT m a
catchError (ListT m (Step m a)
m) e -> ListT m a
k = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError m (Step m a)
m (forall (m :: * -> *) a. ListT m a -> m (Step m a)
next forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> ListT m a
k))
instance MonadReader i m => MonadReader i (ListT m) where
ask :: ListT m i
ask = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall r (m :: * -> *). MonadReader r m => m r
ask
local :: forall a. (i -> i) -> ListT m a -> ListT m a
local i -> i
k (ListT m (Step m a)
m) = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local i -> i
k m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local i -> i
k ListT m a
l)) )
reader :: forall a. (i -> a) -> ListT m a
reader i -> a
k = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
reader i -> a
k)
instance MonadState s m => MonadState s (ListT m) where
get :: ListT m s
get = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall s (m :: * -> *). MonadState s m => m s
get
put :: s -> ListT m ()
put s
x = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall s (m :: * -> *). MonadState s m => s -> m ()
put s
x)
state :: forall a. (s -> (a, s)) -> ListT m a
state s -> (a, s)
k = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state s -> (a, s)
k)
instance MFunctor ListT where
hoist :: forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a) -> ListT m b -> ListT n b
hoist forall a. m a -> n a
f ListT m b
xs = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall a. m a -> n a
f (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> n a
f) (forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m b
xs)))
instance (Monad m, Num a) => Num (ListT m a) where
fromInteger :: Integer -> ListT m a
fromInteger Integer
n = forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. Num a => Integer -> a
fromInteger Integer
n)
negate :: ListT m a -> ListT m a
negate = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
negate
abs :: ListT m a -> ListT m a
abs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
abs
signum :: ListT m a -> ListT m a
signum = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
signum
+ :: ListT m a -> ListT m a -> ListT m a
(+) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Num a => a -> a -> a
(+)
* :: ListT m a -> ListT m a -> ListT m a
(*) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Num a => a -> a -> a
(*)
(-) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (-)
instance (Monad m, Fractional a) => Fractional (ListT m a) where
fromRational :: Rational -> ListT m a
fromRational Rational
n = forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. Fractional a => Rational -> a
fromRational Rational
n)
recip :: ListT m a -> ListT m a
recip = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Fractional a => a -> a
recip
/ :: ListT m a -> ListT m a -> ListT m a
(/) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Fractional a => a -> a -> a
(/)
instance (Monad m, Floating a) => Floating (ListT m a) where
pi :: ListT m a
pi = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Floating a => a
pi
exp :: ListT m a -> ListT m a
exp = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
exp
sqrt :: ListT m a -> ListT m a
sqrt = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sqrt
log :: ListT m a -> ListT m a
log = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
log
sin :: ListT m a -> ListT m a
sin = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sin
tan :: ListT m a -> ListT m a
tan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
tan
cos :: ListT m a -> ListT m a
cos = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
cos
asin :: ListT m a -> ListT m a
asin = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
asin
atan :: ListT m a -> ListT m a
atan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
atan
acos :: ListT m a -> ListT m a
acos = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
acos
sinh :: ListT m a -> ListT m a
sinh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sinh
tanh :: ListT m a -> ListT m a
tanh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
tanh
cosh :: ListT m a -> ListT m a
cosh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
cosh
asinh :: ListT m a -> ListT m a
asinh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
asinh
atanh :: ListT m a -> ListT m a
atanh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
atanh
acosh :: ListT m a -> ListT m a
acosh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
acosh
** :: ListT m a -> ListT m a -> ListT m a
(**) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Floating a => a -> a -> a
(**)
logBase :: ListT m a -> ListT m a -> ListT m a
logBase = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Floating a => a -> a -> a
logBase
runListT :: Monad m => ListT m a -> m ()
runListT :: forall (m :: * -> *) a. Monad m => ListT m a -> m ()
runListT (ListT m (Step m a)
m) = do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Cons a
_ ListT m a
l' -> forall (m :: * -> *) a. Monad m => ListT m a -> m ()
runListT ListT m a
l'
fold :: Monad m => (x -> a -> x) -> x -> (x -> b) -> ListT m a -> m b
fold :: forall (m :: * -> *) x a b.
Monad m =>
(x -> a -> x) -> x -> (x -> b) -> ListT m a -> m b
fold x -> a -> x
step x
begin x -> b
done ListT m a
l = forall {m :: * -> *}. Monad m => x -> ListT m a -> m b
go x
begin ListT m a
l
where
go :: x -> ListT m a -> m b
go !x
x (ListT m (Step m a)
m) = do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Cons a
a ListT m a
l' -> x -> ListT m a -> m b
go (x -> a -> x
step x
x a
a) ListT m a
l'
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return (x -> b
done x
x)
foldM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> ListT m a -> m b
foldM :: forall (m :: * -> *) x a b.
Monad m =>
(x -> a -> m x) -> m x -> (x -> m b) -> ListT m a -> m b
foldM x -> a -> m x
step m x
begin x -> m b
done ListT m a
l0 = do
x
x0 <- m x
begin
x -> ListT m a -> m b
go x
x0 ListT m a
l0
where
go :: x -> ListT m a -> m b
go !x
x (ListT m (Step m a)
m) = do
Step m a
s <- m (Step m a)
m
case Step m a
s of
Cons a
a ListT m a
l' -> do
x
x' <- x -> a -> m x
step x
x a
a
x -> ListT m a -> m b
go x
x' ListT m a
l'
Step m a
Nil -> x -> m b
done x
x
select :: (Foldable f, Alternative m) => f a -> m a
select :: forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f a -> m a
select = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
Data.Foldable.foldr forall {f :: * -> *} {a}. Alternative f => a -> f a -> f a
cons forall (f :: * -> *) a. Alternative f => f a
empty
where
cons :: a -> f a -> f a
cons a
x f a
xs = forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> f a
xs
take :: Monad m => Int -> ListT m a -> ListT m a
take :: forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
take Int
n ListT m a
l
| Int
n forall a. Ord a => a -> a -> Bool
<= Int
0 = forall (f :: * -> *) a. Alternative f => f a
empty
| Bool
otherwise = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
case Step m a
s of
Cons a
a ListT m a
l' -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
a (forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
take (Int
nforall a. Num a => a -> a -> a
-Int
1) ListT m a
l'))
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil)
drop :: Monad m => Int -> ListT m a -> ListT m a
drop :: forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
drop Int
n ListT m a
l
| Int
n forall a. Ord a => a -> a -> Bool
<= Int
0 = ListT m a
l
| Bool
otherwise = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
case Step m a
s of
Cons a
_ ListT m a
l' -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
drop (Int
nforall a. Num a => a -> a -> a
-Int
1) ListT m a
l')
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil)
dropWhile :: Monad m => (a -> Bool) -> ListT m a -> ListT m a
dropWhile :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
dropWhile a -> Bool
pred ListT m a
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
n <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
case Step m a
n of
Cons a
x ListT m a
l'
| a -> Bool
pred a
x -> forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
dropWhile a -> Bool
pred ListT m a
l')
| Bool
otherwise -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
l')
Step m a
Nil -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil )
takeWhile :: Monad m => (a -> Bool) -> ListT m a -> ListT m a
takeWhile :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
takeWhile a -> Bool
pred ListT m a
l = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
n <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
case Step m a
n of
Cons a
x ListT m a
l' | a -> Bool
pred a
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
takeWhile a -> Bool
pred ListT m a
l'))
Step m a
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil )
unfold :: Monad m => (b -> m (Maybe (a, b))) -> b -> ListT m a
unfold :: forall (m :: * -> *) b a.
Monad m =>
(b -> m (Maybe (a, b))) -> b -> ListT m a
unfold b -> m (Maybe (a, b))
step = b -> ListT m a
loop
where
loop :: b -> ListT m a
loop b
seed = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Maybe (a, b)
mx <- b -> m (Maybe (a, b))
step b
seed
case Maybe (a, b)
mx of
Just (a
x, b
seed') -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (b -> ListT m a
loop b
seed'))
Maybe (a, b)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil)
zip :: Monad m => ListT m a -> ListT m b -> ListT m (a, b)
zip :: forall (m :: * -> *) a b.
Monad m =>
ListT m a -> ListT m b -> ListT m (a, b)
zip ListT m a
xs ListT m b
ys = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
sx <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
xs
Step m b
sy <- forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m b
ys
case (Step m a
sx, Step m b
sy) of
(Cons a
x ListT m a
xs', Cons b
y ListT m b
ys') -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons (a
x, b
y) (forall (m :: * -> *) a b.
Monad m =>
ListT m a -> ListT m b -> ListT m (a, b)
zip ListT m a
xs' ListT m b
ys'))
(Step m a, Step m b)
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall (m :: * -> *) a. Step m a
Nil)
data Step m a = Cons a (ListT m a) | Nil
deriving (forall a. Step m a -> Bool
forall m a. Monoid m => (a -> m) -> Step m a -> m
forall a b. (a -> b -> b) -> b -> Step m a -> b
forall (m :: * -> *) a. (Foldable m, Eq a) => a -> Step m a -> Bool
forall (m :: * -> *) a. (Foldable m, Num a) => Step m a -> a
forall (m :: * -> *) a. (Foldable m, Ord a) => Step m a -> a
forall (m :: * -> *) m. (Foldable m, Monoid m) => Step m m -> m
forall (m :: * -> *) a. Foldable m => Step m a -> Bool
forall (m :: * -> *) a. Foldable m => Step m a -> Int
forall (m :: * -> *) a. Foldable m => Step m a -> [a]
forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> Step m a -> a
forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> Step m a -> m
forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> Step m a -> b
forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> Step m a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Step m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => Step m a -> a
sum :: forall a. Num a => Step m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => Step m a -> a
minimum :: forall a. Ord a => Step m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => Step m a -> a
maximum :: forall a. Ord a => Step m a -> a
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => Step m a -> a
elem :: forall a. Eq a => a -> Step m a -> Bool
$celem :: forall (m :: * -> *) a. (Foldable m, Eq a) => a -> Step m a -> Bool
length :: forall a. Step m a -> Int
$clength :: forall (m :: * -> *) a. Foldable m => Step m a -> Int
null :: forall a. Step m a -> Bool
$cnull :: forall (m :: * -> *) a. Foldable m => Step m a -> Bool
toList :: forall a. Step m a -> [a]
$ctoList :: forall (m :: * -> *) a. Foldable m => Step m a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Step m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> Step m a -> a
foldr1 :: forall a. (a -> a -> a) -> Step m a -> a
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> Step m a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Step m a -> b
$cfoldl' :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> Step m a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Step m a -> b
$cfoldl :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> Step m a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Step m a -> b
$cfoldr' :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> Step m a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Step m a -> b
$cfoldr :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> Step m a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Step m a -> m
$cfoldMap' :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> Step m a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Step m a -> m
$cfoldMap :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> Step m a -> m
fold :: forall m. Monoid m => Step m m -> m
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => Step m m -> m
Foldable, forall {m :: * -> *}. (Monad m, Traversable m) => Functor (Step m)
forall {m :: * -> *}. (Monad m, Traversable m) => Foldable (Step m)
forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
Step m (m a) -> m (Step m a)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
Step m (f a) -> f (Step m a)
forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> Step m a -> m (Step m b)
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> Step m a -> f (Step m b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Step m a -> f (Step m b)
sequence :: forall (m :: * -> *) a. Monad m => Step m (m a) -> m (Step m a)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
Step m (m a) -> m (Step m a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Step m a -> m (Step m b)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> Step m a -> m (Step m b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Step m (f a) -> f (Step m a)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
Step m (f a) -> f (Step m a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Step m a -> f (Step m b)
$ctraverse :: forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> Step m a -> f (Step m b)
Traversable)
instance Monad m => Functor (Step m) where
fmap :: forall a b. (a -> b) -> Step m a -> Step m b
fmap a -> b
_ Step m a
Nil = forall (m :: * -> *) a. Step m a
Nil
fmap a -> b
k (Cons a
x ListT m a
l) = forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons (a -> b
k a
x) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
k ListT m a
l)
instance MFunctor Step where
hoist :: forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a) -> Step m b -> Step n b
hoist forall a. m a -> n a
_ Step m b
Nil = forall (m :: * -> *) a. Step m a
Nil
hoist forall a. m a -> n a
f (Cons b
x ListT m b
xs) = forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons b
x (forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> n a
f ListT m b
xs)
newtype ZipListT m a = ZipListT { forall (m :: * -> *) a. ZipListT m a -> ListT m a
getZipListT :: ListT m a }
deriving (forall a b. a -> ZipListT m b -> ZipListT m a
forall a b. (a -> b) -> ZipListT m a -> ZipListT m b
forall (m :: * -> *) a b.
Monad m =>
a -> ZipListT m b -> ZipListT m a
forall (m :: * -> *) a b.
Monad m =>
(a -> b) -> ZipListT m a -> ZipListT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ZipListT m b -> ZipListT m a
$c<$ :: forall (m :: * -> *) a b.
Monad m =>
a -> ZipListT m b -> ZipListT m a
fmap :: forall a b. (a -> b) -> ZipListT m a -> ZipListT m b
$cfmap :: forall (m :: * -> *) a b.
Monad m =>
(a -> b) -> ZipListT m a -> ZipListT m b
Functor, forall a. ZipListT m a
forall a. ZipListT m a -> ZipListT m [a]
forall a. ZipListT m a -> ZipListT m a -> ZipListT m a
forall {m :: * -> *}. Monad m => Applicative (ZipListT m)
forall (m :: * -> *) a. Monad m => ZipListT m a
forall (m :: * -> *) a. Monad m => ZipListT m a -> ZipListT m [a]
forall (m :: * -> *) a.
Monad m =>
ZipListT m a -> ZipListT m a -> ZipListT m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: forall a. ZipListT m a -> ZipListT m [a]
$cmany :: forall (m :: * -> *) a. Monad m => ZipListT m a -> ZipListT m [a]
some :: forall a. ZipListT m a -> ZipListT m [a]
$csome :: forall (m :: * -> *) a. Monad m => ZipListT m a -> ZipListT m [a]
<|> :: forall a. ZipListT m a -> ZipListT m a -> ZipListT m a
$c<|> :: forall (m :: * -> *) a.
Monad m =>
ZipListT m a -> ZipListT m a -> ZipListT m a
empty :: forall a. ZipListT m a
$cempty :: forall (m :: * -> *) a. Monad m => ZipListT m a
Alternative, forall a. Eq a => a -> ZipListT m a -> Bool
forall a. Num a => ZipListT m a -> a
forall a. Ord a => ZipListT m a -> a
forall m. Monoid m => ZipListT m m -> m
forall a. ZipListT m a -> Bool
forall a. ZipListT m a -> Int
forall a. ZipListT m a -> [a]
forall a. (a -> a -> a) -> ZipListT m a -> a
forall m a. Monoid m => (a -> m) -> ZipListT m a -> m
forall b a. (b -> a -> b) -> b -> ZipListT m a -> b
forall a b. (a -> b -> b) -> b -> ZipListT m a -> b
forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ZipListT m a -> Bool
forall (m :: * -> *) a. (Foldable m, Num a) => ZipListT m a -> a
forall (m :: * -> *) a. (Foldable m, Ord a) => ZipListT m a -> a
forall (m :: * -> *) m. (Foldable m, Monoid m) => ZipListT m m -> m
forall (m :: * -> *) a. Foldable m => ZipListT m a -> Bool
forall (m :: * -> *) a. Foldable m => ZipListT m a -> Int
forall (m :: * -> *) a. Foldable m => ZipListT m a -> [a]
forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ZipListT m a -> a
forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ZipListT m a -> m
forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ZipListT m a -> b
forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ZipListT m a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ZipListT m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => ZipListT m a -> a
sum :: forall a. Num a => ZipListT m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => ZipListT m a -> a
minimum :: forall a. Ord a => ZipListT m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ZipListT m a -> a
maximum :: forall a. Ord a => ZipListT m a -> a
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ZipListT m a -> a
elem :: forall a. Eq a => a -> ZipListT m a -> Bool
$celem :: forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ZipListT m a -> Bool
length :: forall a. ZipListT m a -> Int
$clength :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> Int
null :: forall a. ZipListT m a -> Bool
$cnull :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> Bool
toList :: forall a. ZipListT m a -> [a]
$ctoList :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ZipListT m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ZipListT m a -> a
foldr1 :: forall a. (a -> a -> a) -> ZipListT m a -> a
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ZipListT m a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ZipListT m a -> b
$cfoldl' :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ZipListT m a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ZipListT m a -> b
$cfoldl :: forall (m :: * -> *) b a.
Foldable m =>
(b -> a -> b) -> b -> ZipListT m a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ZipListT m a -> b
$cfoldr' :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ZipListT m a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ZipListT m a -> b
$cfoldr :: forall (m :: * -> *) a b.
Foldable m =>
(a -> b -> b) -> b -> ZipListT m a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ZipListT m a -> m
$cfoldMap' :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ZipListT m a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ZipListT m a -> m
$cfoldMap :: forall (m :: * -> *) m a.
(Foldable m, Monoid m) =>
(a -> m) -> ZipListT m a -> m
fold :: forall m. Monoid m => ZipListT m m -> m
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => ZipListT m m -> m
Foldable, forall {m :: * -> *}.
(Monad m, Traversable m) =>
Functor (ZipListT m)
forall {m :: * -> *}.
(Monad m, Traversable m) =>
Foldable (ZipListT m)
forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ZipListT m (m a) -> m (ZipListT m a)
forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ZipListT m (f a) -> f (ZipListT m a)
forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b)
sequence :: forall (m :: * -> *) a.
Monad m =>
ZipListT m (m a) -> m (ZipListT m a)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ZipListT m (m a) -> m (ZipListT m a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ZipListT m (f a) -> f (ZipListT m a)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ZipListT m (f a) -> f (ZipListT m a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b)
$ctraverse :: forall (m :: * -> *) (f :: * -> *) a b.
(Monad m, Traversable m, Applicative f) =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b)
Traversable, ZipListT m a
ZipListT m a -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
forall {m :: * -> *} {a}.
(Monad m, Floating a) =>
Fractional (ZipListT m a)
forall (m :: * -> *) a. (Monad m, Floating a) => ZipListT m a
forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
log1mexp :: ZipListT m a -> ZipListT m a
$clog1mexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log1pexp :: ZipListT m a -> ZipListT m a
$clog1pexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
expm1 :: ZipListT m a -> ZipListT m a
$cexpm1 :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log1p :: ZipListT m a -> ZipListT m a
$clog1p :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
atanh :: ZipListT m a -> ZipListT m a
$catanh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
acosh :: ZipListT m a -> ZipListT m a
$cacosh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
asinh :: ZipListT m a -> ZipListT m a
$casinh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
tanh :: ZipListT m a -> ZipListT m a
$ctanh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
cosh :: ZipListT m a -> ZipListT m a
$ccosh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
sinh :: ZipListT m a -> ZipListT m a
$csinh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
atan :: ZipListT m a -> ZipListT m a
$catan :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
acos :: ZipListT m a -> ZipListT m a
$cacos :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
asin :: ZipListT m a -> ZipListT m a
$casin :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
tan :: ZipListT m a -> ZipListT m a
$ctan :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
cos :: ZipListT m a -> ZipListT m a
$ccos :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
sin :: ZipListT m a -> ZipListT m a
$csin :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
logBase :: ZipListT m a -> ZipListT m a -> ZipListT m a
$clogBase :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
** :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c** :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
sqrt :: ZipListT m a -> ZipListT m a
$csqrt :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log :: ZipListT m a -> ZipListT m a
$clog :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
exp :: ZipListT m a -> ZipListT m a
$cexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
pi :: ZipListT m a
$cpi :: forall (m :: * -> *) a. (Monad m, Floating a) => ZipListT m a
Floating, Rational -> ZipListT m a
ZipListT m a -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
forall {m :: * -> *} {a}.
(Monad m, Fractional a) =>
Num (ZipListT m a)
forall (m :: * -> *) a.
(Monad m, Fractional a) =>
Rational -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
fromRational :: Rational -> ZipListT m a
$cfromRational :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
Rational -> ZipListT m a
recip :: ZipListT m a -> ZipListT m a
$crecip :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a
/ :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c/ :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
Fractional, Integer -> ZipListT m a
ZipListT m a -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
forall (m :: * -> *) a. (Monad m, Num a) => Integer -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
fromInteger :: Integer -> ZipListT m a
$cfromInteger :: forall (m :: * -> *) a. (Monad m, Num a) => Integer -> ZipListT m a
signum :: ZipListT m a -> ZipListT m a
$csignum :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
abs :: ZipListT m a -> ZipListT m a
$cabs :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
negate :: ZipListT m a -> ZipListT m a
$cnegate :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
* :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c* :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
- :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c- :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
+ :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c+ :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
Num, NonEmpty (ZipListT m a) -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
forall b. Integral b => b -> ZipListT m a -> ZipListT m a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
NonEmpty (ZipListT m a) -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
forall (m :: * -> *) a b.
(Monad m, Semigroup a, Integral b) =>
b -> ZipListT m a -> ZipListT m a
stimes :: forall b. Integral b => b -> ZipListT m a -> ZipListT m a
$cstimes :: forall (m :: * -> *) a b.
(Monad m, Semigroup a, Integral b) =>
b -> ZipListT m a -> ZipListT m a
sconcat :: NonEmpty (ZipListT m a) -> ZipListT m a
$csconcat :: forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
NonEmpty (ZipListT m a) -> ZipListT m a
<> :: ZipListT m a -> ZipListT m a -> ZipListT m a
$c<> :: forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
Semigroup, ZipListT m a
[ZipListT m a] -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall {m :: * -> *} {a}.
(Monad m, Monoid a) =>
Semigroup (ZipListT m a)
forall (m :: * -> *) a. (Monad m, Monoid a) => ZipListT m a
forall (m :: * -> *) a.
(Monad m, Monoid a) =>
[ZipListT m a] -> ZipListT m a
forall (m :: * -> *) a.
(Monad m, Monoid a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
mconcat :: [ZipListT m a] -> ZipListT m a
$cmconcat :: forall (m :: * -> *) a.
(Monad m, Monoid a) =>
[ZipListT m a] -> ZipListT m a
mappend :: ZipListT m a -> ZipListT m a -> ZipListT m a
$cmappend :: forall (m :: * -> *) a.
(Monad m, Monoid a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
mempty :: ZipListT m a
$cmempty :: forall (m :: * -> *) a. (Monad m, Monoid a) => ZipListT m a
Monoid)
instance Monad m => Applicative (ZipListT m) where
pure :: forall a. a -> ZipListT m a
pure a
x = forall (m :: * -> *) a. ListT m a -> ZipListT m a
ZipListT ListT m a
go
where
go :: ListT m a
go = forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
go))
ZipListT ListT m (a -> b)
fs <*> :: forall a b. ZipListT m (a -> b) -> ZipListT m a -> ZipListT m b
<*> ZipListT ListT m a
xs = forall (m :: * -> *) a. ListT m a -> ZipListT m a
ZipListT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a b. (a -> b) -> a -> b
($)) (forall (m :: * -> *) a b.
Monad m =>
ListT m a -> ListT m b -> ListT m (a, b)
zip ListT m (a -> b)
fs ListT m a
xs))