{-# 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 m. Monoid m => ListT m m -> m)
-> (forall m a. Monoid m => (a -> m) -> ListT m a -> m)
-> (forall m a. Monoid m => (a -> m) -> ListT m a -> m)
-> (forall a b. (a -> b -> b) -> b -> ListT m a -> b)
-> (forall a b. (a -> b -> b) -> b -> ListT m a -> b)
-> (forall b a. (b -> a -> b) -> b -> ListT m a -> b)
-> (forall b a. (b -> a -> b) -> b -> ListT m a -> b)
-> (forall a. (a -> a -> a) -> ListT m a -> a)
-> (forall a. (a -> a -> a) -> ListT m a -> a)
-> (forall a. ListT m a -> [a])
-> (forall a. ListT m a -> Bool)
-> (forall a. ListT m a -> Int)
-> (forall a. Eq a => a -> ListT m a -> Bool)
-> (forall a. Ord a => ListT m a -> a)
-> (forall a. Ord a => ListT m a -> a)
-> (forall a. Num a => ListT m a -> a)
-> (forall a. Num a => ListT m a -> a)
-> Foldable (ListT m)
forall a. Eq a => a -> ListT m a -> Bool
forall a. Num a => ListT m a -> a
forall a. Ord a => ListT m a -> a
forall m. Monoid m => ListT m m -> m
forall a. ListT m a -> Bool
forall a. ListT m a -> Int
forall a. ListT m a -> [a]
forall a. (a -> a -> a) -> ListT m a -> a
forall m a. Monoid m => (a -> m) -> ListT m a -> m
forall b a. (b -> a -> b) -> b -> ListT m a -> b
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
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => ListT m m -> m
fold :: forall m. Monoid m => ListT m m -> 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
foldMap' :: forall m a. Monoid m => (a -> m) -> ListT m a -> m
$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
foldr' :: forall a b. (a -> b -> 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
foldl' :: forall b a. (b -> a -> b) -> b -> ListT m a -> b
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ListT m a -> a
foldr1 :: forall a. (a -> a -> a) -> ListT m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ListT m a -> a
foldl1 :: forall a. (a -> a -> a) -> ListT m a -> a
$ctoList :: forall (m :: * -> *) a. Foldable m => ListT m a -> [a]
toList :: forall a. ListT m a -> [a]
$cnull :: forall (m :: * -> *) a. Foldable m => ListT m a -> Bool
null :: forall a. ListT m a -> Bool
$clength :: forall (m :: * -> *) a. Foldable m => ListT m a -> Int
length :: forall a. ListT m a -> Int
$celem :: forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ListT m a -> Bool
elem :: forall a. Eq a => a -> ListT m a -> Bool
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ListT m a -> a
maximum :: forall a. Ord a => ListT m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ListT m a -> a
minimum :: forall a. Ord a => ListT m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => ListT m a -> a
sum :: forall a. Num a => ListT m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => ListT m a -> a
product :: forall a. Num a => ListT m a -> a
Foldable, Functor (ListT m)
Foldable (ListT m)
(Functor (ListT m), Foldable (ListT m)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListT m a -> f (ListT m b))
-> (forall (f :: * -> *) a.
Applicative f =>
ListT m (f a) -> f (ListT m a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ListT m a -> m (ListT m b))
-> (forall (m :: * -> *) a.
Monad m =>
ListT m (m a) -> m (ListT m a))
-> Traversable (ListT m)
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 (m :: * -> *) a. Monad m => ListT m (m a) -> m (ListT m a)
forall (f :: * -> *) a.
Applicative f =>
ListT m (f a) -> f (ListT m a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ListT m a -> m (ListT m b)
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)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListT m a -> f (ListT m b)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ListT m (f a) -> f (ListT m a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ListT m (f a) -> f (ListT m a)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ListT m a -> m (ListT m b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ListT m a -> m (ListT m b)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ListT m (m a) -> m (ListT m a)
sequence :: forall (m :: * -> *) a. Monad m => ListT m (m a) -> m (ListT m a)
Traversable)
instance MonadTrans ListT where
lift :: forall (m :: * -> *) a. Monad m => m a -> ListT m a
lift m a
m = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
a
x <- m a
m
Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
forall a. ListT m a
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) = m (Step m b) -> ListT m b
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- m (Step m a)
m
Step m b -> m (Step m b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ((a -> b) -> Step m a -> Step m b
forall a b. (a -> b) -> Step m a -> Step m b
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
forall a. ListT m a
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 = m (Step m b) -> ListT m b
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 -> Step m b -> m (Step m b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m b
forall (m :: * -> *) a. Step m a
Nil
Cons a -> b
f ListT m (a -> b)
l' -> ListT m b -> m (Step m b)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ((a -> b) -> ListT m a -> ListT m b
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ListT m a
l ListT m b -> ListT m b -> ListT m b
forall a. ListT m a -> ListT m a -> ListT m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m (a -> b)
l' ListT m (a -> b) -> ListT m a -> ListT m b
forall a b. ListT m (a -> b) -> ListT m a -> ListT m b
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 = m (Step m b) -> ListT m b
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 -> Step m b -> m (Step m b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m b
forall (m :: * -> *) a. Step m a
Nil
Cons a
_ ListT m a
l' -> ListT m b -> m (Step m b)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (ListT m b
l ListT m b -> ListT m b -> ListT m b
forall a. ListT m a -> ListT m a -> ListT m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' ListT m a -> ListT m b -> ListT m b
forall a b. ListT m a -> ListT m b -> ListT m b
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 = m (Step m a) -> ListT m a
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 -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l' -> ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ((a
x a -> ListT m b -> ListT m a
forall a b. a -> ListT m b -> ListT m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ListT m b
l) ListT m a -> ListT m a -> ListT m a
forall a. ListT m a -> ListT m a -> ListT m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' ListT m a -> ListT m b -> ListT m a
forall a b. ListT m a -> ListT m b -> ListT m a
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 = a -> ListT m a
forall a. a -> ListT m a
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 = m (Step m b) -> ListT m b
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 -> Step m b -> m (Step m b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m b
forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l' -> ListT m b -> m (Step m b)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (a -> ListT m b
k a
x ListT m b -> ListT m b -> ListT m b
forall a. ListT m a -> ListT m a -> ListT m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ListT m a
l' ListT m a -> (a -> ListT m b) -> ListT m b
forall a b. ListT m a -> (a -> ListT m b) -> ListT m b
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 = m (Step m a) -> ListT m a
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 -> ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
l
Cons a
x ListT m a
l' -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (ListT m a
l' ListT m a -> ListT m a -> ListT m a
forall a. ListT m a -> ListT m a -> ListT m a
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 = ListT m a
forall a. ListT m a
forall (f :: * -> *) a. Alternative f => f a
empty
mplus :: forall a. ListT m a -> ListT m a -> ListT m a
mplus = ListT m a -> ListT m a -> ListT m a
forall a. ListT m a -> ListT m a -> ListT m a
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
_ = ListT m a
forall a. ListT m a
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
(<>) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
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 = a -> ListT m a
forall a. a -> ListT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
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 = m a -> ListT m a
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO a -> m a
forall a. IO a -> m a
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (e -> m (Step m a)
forall a. e -> m a
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (m (Step m a) -> (e -> m (Step m a)) -> m (Step m a)
forall a. m a -> (e -> m a) -> m a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError m (Step m a)
m (ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (ListT m a -> m (Step m a))
-> (e -> ListT m a) -> e -> m (Step m a)
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 = m i -> ListT m i
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m i
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) = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- (i -> i) -> m (Step m a) -> m (Step m a)
forall a. (i -> i) -> m a -> m a
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 -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
forall (m :: * -> *) a. Step m a
Nil
Cons a
x ListT m a
l -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ((i -> i) -> ListT m a -> ListT m a
forall a. (i -> i) -> ListT m a -> ListT m a
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 = m a -> ListT m a
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((i -> a) -> m a
forall a. (i -> a) -> m a
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 = m s -> ListT m s
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m s
forall s (m :: * -> *). MonadState s m => m s
get
put :: s -> ListT m ()
put s
x = m () -> ListT m ()
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> m ()
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 = m a -> ListT m a
forall (m :: * -> *) a. Monad m => m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((s -> (a, s)) -> m a
forall a. (s -> (a, s)) -> m a
forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state s -> (a, s)
k)
instance MFunctor ListT where
#if MIN_VERSION_base(4,8,0)
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 = n (Step n b) -> ListT n b
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (m (Step n b) -> n (Step n b)
forall a. m a -> n a
f ((Step m b -> Step n b) -> m (Step m b) -> m (Step n b)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall a. m a -> n a) -> Step m b -> Step n b
forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a) -> Step m b -> Step n b
hoist m a -> n a
forall a. m a -> n a
f) (ListT m b -> m (Step m b)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m b
xs)))
#else
hoist f xs = ListT (f (next xs >>= \x -> return (hoist f x)))
#endif
instance (Monad m, Num a) => Num (ListT m a) where
fromInteger :: Integer -> ListT m a
fromInteger Integer
n = a -> ListT m a
forall a. a -> ListT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> a
forall a. Num a => Integer -> a
fromInteger Integer
n)
negate :: ListT m a -> ListT m a
negate = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
negate
abs :: ListT m a -> ListT m a
abs = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
abs
signum :: ListT m a -> ListT m a
signum = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
signum
+ :: ListT m a -> ListT m a -> ListT m a
(+) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(+)
* :: ListT m a -> ListT m a -> ListT m a
(*) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(*)
(-) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
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 = a -> ListT m a
forall a. a -> ListT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Rational -> a
forall a. Fractional a => Rational -> a
fromRational Rational
n)
recip :: ListT m a -> ListT m a
recip = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Fractional a => a -> a
recip
/ :: ListT m a -> ListT m a -> ListT m a
(/) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Fractional a => a -> a -> a
(/)
instance (Monad m, Floating a) => Floating (ListT m a) where
pi :: ListT m a
pi = a -> ListT m a
forall a. a -> ListT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Floating a => a
pi
exp :: ListT m a -> ListT m a
exp = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
exp
sqrt :: ListT m a -> ListT m a
sqrt = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sqrt
log :: ListT m a -> ListT m a
log = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
log
sin :: ListT m a -> ListT m a
sin = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sin
tan :: ListT m a -> ListT m a
tan = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
tan
cos :: ListT m a -> ListT m a
cos = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
cos
asin :: ListT m a -> ListT m a
asin = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
asin
atan :: ListT m a -> ListT m a
atan = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
atan
acos :: ListT m a -> ListT m a
acos = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
acos
sinh :: ListT m a -> ListT m a
sinh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sinh
tanh :: ListT m a -> ListT m a
tanh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
tanh
cosh :: ListT m a -> ListT m a
cosh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
cosh
asinh :: ListT m a -> ListT m a
asinh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
asinh
atanh :: ListT m a -> ListT m a
atanh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
atanh
acosh :: ListT m a -> ListT m a
acosh = (a -> a) -> ListT m a -> ListT m a
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
acosh
** :: ListT m a -> ListT m a -> ListT m a
(**) = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Floating a => a -> a -> a
(**)
logBase :: ListT m a -> ListT m a -> ListT m a
logBase = (a -> a -> a) -> ListT m a -> ListT m a -> ListT m a
forall a b c. (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
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 -> () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Cons a
_ ListT m a
l' -> ListT m a -> m ()
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 = x -> ListT m a -> m b
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 -> b -> m b
forall a. a -> m a
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 = (a -> m a -> m a) -> m a -> f a -> m a
forall a b. (a -> b -> b) -> b -> f a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
Data.Foldable.foldr a -> m a -> m a
forall {f :: * -> *} {a}. Alternative f => a -> f a -> f a
cons m a
forall a. m a
forall (f :: * -> *) a. Alternative f => f a
empty
where
cons :: a -> f a -> f a
cons a
x f a
xs = a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x f a -> f a -> f a
forall a. f a -> f a -> f a
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 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = ListT m a
forall a. ListT m a
forall (f :: * -> *) a. Alternative f => f a
empty
| Bool
otherwise = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- ListT m a -> m (Step m a)
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' -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
a (Int -> ListT m a -> ListT m a
forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
take (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) ListT m a
l'))
Step m a
Nil -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = ListT m a
l
| Bool
otherwise = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
s <- ListT m a -> m (Step m a)
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' -> ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next (Int -> ListT m a -> ListT m a
forall (m :: * -> *) a. Monad m => Int -> ListT m a -> ListT m a
drop (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) ListT m a
l')
Step m a
Nil -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
n <- ListT m a -> m (Step m a)
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 -> ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ((a -> Bool) -> ListT m a -> ListT m a
forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
dropWhile a -> Bool
pred ListT m a
l')
| Bool
otherwise -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
l')
Step m a
Nil -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
n <- ListT m a -> m (Step m a)
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 -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ((a -> Bool) -> ListT m a -> ListT m a
forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> ListT m a -> ListT m a
takeWhile a -> Bool
pred ListT m a
l'))
Step m a
_ -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 = m (Step m a) -> ListT m a
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') -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x (b -> ListT m a
loop b
seed'))
Maybe (a, b)
Nothing -> Step m a -> m (Step m a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m a
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 = m (Step m (a, b)) -> ListT m (a, b)
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (do
Step m a
sx <- ListT m a -> m (Step m a)
forall (m :: * -> *) a. ListT m a -> m (Step m a)
next ListT m a
xs
Step m b
sy <- ListT m b -> m (Step m b)
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') -> Step m (a, b) -> m (Step m (a, b))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ((a, b) -> ListT m (a, b) -> Step m (a, b)
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons (a
x, b
y) (ListT m a -> ListT m b -> ListT m (a, b)
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)
_ -> Step m (a, b) -> m (Step m (a, b))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Step m (a, b)
forall (m :: * -> *) a. Step m a
Nil)
data Step m a = Cons a (ListT m a) | Nil
deriving ((forall m. Monoid m => Step m m -> m)
-> (forall m a. Monoid m => (a -> m) -> Step m a -> m)
-> (forall m a. Monoid m => (a -> m) -> Step m a -> m)
-> (forall a b. (a -> b -> b) -> b -> Step m a -> b)
-> (forall a b. (a -> b -> b) -> b -> Step m a -> b)
-> (forall b a. (b -> a -> b) -> b -> Step m a -> b)
-> (forall b a. (b -> a -> b) -> b -> Step m a -> b)
-> (forall a. (a -> a -> a) -> Step m a -> a)
-> (forall a. (a -> a -> a) -> Step m a -> a)
-> (forall a. Step m a -> [a])
-> (forall a. Step m a -> Bool)
-> (forall a. Step m a -> Int)
-> (forall a. Eq a => a -> Step m a -> Bool)
-> (forall a. Ord a => Step m a -> a)
-> (forall a. Ord a => Step m a -> a)
-> (forall a. Num a => Step m a -> a)
-> (forall a. Num a => Step m a -> a)
-> Foldable (Step m)
forall a. Eq a => a -> Step m a -> Bool
forall a. Num a => Step m a -> a
forall a. Ord a => Step m a -> a
forall m. Monoid m => Step m m -> m
forall a. Step m a -> Bool
forall a. Step m a -> Int
forall a. Step m a -> [a]
forall a. (a -> a -> a) -> Step m a -> a
forall m a. Monoid m => (a -> m) -> Step m a -> m
forall b a. (b -> a -> b) -> b -> Step m a -> b
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
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => Step m m -> m
fold :: forall m. Monoid m => Step m m -> 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
foldMap' :: forall m a. Monoid m => (a -> m) -> Step m a -> m
$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
foldr' :: forall a b. (a -> b -> 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
foldl' :: forall b a. (b -> a -> b) -> b -> Step m a -> b
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> Step m a -> a
foldr1 :: forall a. (a -> a -> a) -> Step m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> Step m a -> a
foldl1 :: forall a. (a -> a -> a) -> Step m a -> a
$ctoList :: forall (m :: * -> *) a. Foldable m => Step m a -> [a]
toList :: forall a. Step m a -> [a]
$cnull :: forall (m :: * -> *) a. Foldable m => Step m a -> Bool
null :: forall a. Step m a -> Bool
$clength :: forall (m :: * -> *) a. Foldable m => Step m a -> Int
length :: forall a. Step m a -> Int
$celem :: forall (m :: * -> *) a. (Foldable m, Eq a) => a -> Step m a -> Bool
elem :: forall a. Eq a => a -> Step m a -> Bool
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => Step m a -> a
maximum :: forall a. Ord a => Step m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => Step m a -> a
minimum :: forall a. Ord a => Step m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => Step m a -> a
sum :: forall a. Num a => Step m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => Step m a -> a
product :: forall a. Num a => Step m a -> a
Foldable, Functor (Step m)
Foldable (Step m)
(Functor (Step m), Foldable (Step m)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Step m a -> f (Step m b))
-> (forall (f :: * -> *) a.
Applicative f =>
Step m (f a) -> f (Step m a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Step m a -> m (Step m b))
-> (forall (m :: * -> *) a.
Monad m =>
Step m (m a) -> m (Step m a))
-> Traversable (Step m)
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 (m :: * -> *) a. Monad m => Step m (m a) -> m (Step m a)
forall (f :: * -> *) a.
Applicative f =>
Step m (f a) -> f (Step m a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Step m a -> m (Step m b)
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)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Step m a -> f (Step m b)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
Step m (f a) -> f (Step m a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Step m (f a) -> f (Step m a)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> Step m a -> m (Step m b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Step m a -> m (Step m b)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
Step m (m a) -> m (Step m a)
sequence :: forall (m :: * -> *) a. Monad m => Step m (m a) -> m (Step m a)
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 = Step m b
forall (m :: * -> *) a. Step m a
Nil
fmap a -> b
k (Cons a
x ListT m a
l) = b -> ListT m b -> Step m b
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons (a -> b
k a
x) ((a -> b) -> ListT m a -> ListT m b
forall a b. (a -> b) -> ListT m a -> ListT m b
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 = Step n b
forall (m :: * -> *) a. Step m a
Nil
hoist forall a. m a -> n a
f (Cons b
x ListT m b
xs) = b -> ListT n b -> Step n b
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons b
x ((forall a. m a -> n a) -> ListT m b -> ListT n b
forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a) -> ListT m b -> ListT n b
hoist m a -> n a
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 -> b) -> ZipListT m a -> ZipListT m b)
-> (forall a b. a -> ZipListT m b -> ZipListT m a)
-> Functor (ZipListT m)
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
$cfmap :: forall (m :: * -> *) a b.
Monad m =>
(a -> b) -> ZipListT m a -> ZipListT m b
fmap :: forall a b. (a -> b) -> ZipListT m a -> ZipListT m b
$c<$ :: forall (m :: * -> *) a b.
Monad m =>
a -> ZipListT m b -> ZipListT m a
<$ :: forall a b. a -> ZipListT m b -> ZipListT m a
Functor, Applicative (ZipListT m)
Applicative (ZipListT m) =>
(forall a. ZipListT m a)
-> (forall a. ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (forall a. ZipListT m a -> ZipListT m [a])
-> (forall a. ZipListT m a -> ZipListT m [a])
-> Alternative (ZipListT m)
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
$cempty :: forall (m :: * -> *) a. Monad m => ZipListT m a
empty :: forall a. ZipListT m a
$c<|> :: forall (m :: * -> *) a.
Monad m =>
ZipListT m a -> ZipListT m a -> ZipListT m a
<|> :: forall a. ZipListT m a -> ZipListT m a -> ZipListT m a
$csome :: forall (m :: * -> *) a. Monad m => ZipListT m a -> ZipListT m [a]
some :: forall a. ZipListT m a -> ZipListT m [a]
$cmany :: forall (m :: * -> *) a. Monad m => ZipListT m a -> ZipListT m [a]
many :: forall a. ZipListT m a -> ZipListT m [a]
Alternative, (forall m. Monoid m => ZipListT m m -> m)
-> (forall m a. Monoid m => (a -> m) -> ZipListT m a -> m)
-> (forall m a. Monoid m => (a -> m) -> ZipListT m a -> m)
-> (forall a b. (a -> b -> b) -> b -> ZipListT m a -> b)
-> (forall a b. (a -> b -> b) -> b -> ZipListT m a -> b)
-> (forall b a. (b -> a -> b) -> b -> ZipListT m a -> b)
-> (forall b a. (b -> a -> b) -> b -> ZipListT m a -> b)
-> (forall a. (a -> a -> a) -> ZipListT m a -> a)
-> (forall a. (a -> a -> a) -> ZipListT m a -> a)
-> (forall a. ZipListT m a -> [a])
-> (forall a. ZipListT m a -> Bool)
-> (forall a. ZipListT m a -> Int)
-> (forall a. Eq a => a -> ZipListT m a -> Bool)
-> (forall a. Ord a => ZipListT m a -> a)
-> (forall a. Ord a => ZipListT m a -> a)
-> (forall a. Num a => ZipListT m a -> a)
-> (forall a. Num a => ZipListT m a -> a)
-> Foldable (ZipListT m)
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
$cfold :: forall (m :: * -> *) m. (Foldable m, Monoid m) => ZipListT m m -> m
fold :: forall m. Monoid m => ZipListT m m -> 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
foldMap' :: forall m a. Monoid m => (a -> m) -> ZipListT m a -> m
$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
foldr' :: forall a b. (a -> b -> 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
foldl' :: forall b a. (b -> a -> b) -> b -> ZipListT m a -> b
$cfoldr1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ZipListT m a -> a
foldr1 :: forall a. (a -> a -> a) -> ZipListT m a -> a
$cfoldl1 :: forall (m :: * -> *) a.
Foldable m =>
(a -> a -> a) -> ZipListT m a -> a
foldl1 :: forall a. (a -> a -> a) -> ZipListT m a -> a
$ctoList :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> [a]
toList :: forall a. ZipListT m a -> [a]
$cnull :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> Bool
null :: forall a. ZipListT m a -> Bool
$clength :: forall (m :: * -> *) a. Foldable m => ZipListT m a -> Int
length :: forall a. ZipListT m a -> Int
$celem :: forall (m :: * -> *) a.
(Foldable m, Eq a) =>
a -> ZipListT m a -> Bool
elem :: forall a. Eq a => a -> ZipListT m a -> Bool
$cmaximum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ZipListT m a -> a
maximum :: forall a. Ord a => ZipListT m a -> a
$cminimum :: forall (m :: * -> *) a. (Foldable m, Ord a) => ZipListT m a -> a
minimum :: forall a. Ord a => ZipListT m a -> a
$csum :: forall (m :: * -> *) a. (Foldable m, Num a) => ZipListT m a -> a
sum :: forall a. Num a => ZipListT m a -> a
$cproduct :: forall (m :: * -> *) a. (Foldable m, Num a) => ZipListT m a -> a
product :: forall a. Num a => ZipListT m a -> a
Foldable, Functor (ZipListT m)
Foldable (ZipListT m)
(Functor (ZipListT m), Foldable (ZipListT m)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b))
-> (forall (f :: * -> *) a.
Applicative f =>
ZipListT m (f a) -> f (ZipListT m a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b))
-> (forall (m :: * -> *) a.
Monad m =>
ZipListT m (m a) -> m (ZipListT m a))
-> Traversable (ZipListT m)
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 (m :: * -> *) a.
Monad m =>
ZipListT m (m a) -> m (ZipListT m a)
forall (f :: * -> *) a.
Applicative f =>
ZipListT m (f a) -> f (ZipListT m a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
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)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ZipListT m a -> f (ZipListT m b)
$csequenceA :: forall (m :: * -> *) (f :: * -> *) a.
(Monad m, Traversable m, Applicative f) =>
ZipListT m (f a) -> f (ZipListT m a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ZipListT m (f a) -> f (ZipListT m a)
$cmapM :: forall (m :: * -> *) (m :: * -> *) a b.
(Monad m, Traversable m, Monad m) =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ZipListT m a -> m (ZipListT m b)
$csequence :: forall (m :: * -> *) (m :: * -> *) a.
(Monad m, Traversable m, Monad m) =>
ZipListT m (m a) -> m (ZipListT m a)
sequence :: forall (m :: * -> *) a.
Monad m =>
ZipListT m (m a) -> m (ZipListT m a)
Traversable, Fractional (ZipListT m a)
ZipListT m a
Fractional (ZipListT m a) =>
ZipListT m a
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> Floating (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
$cpi :: forall (m :: * -> *) a. (Monad m, Floating a) => ZipListT m a
pi :: ZipListT m a
$cexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
exp :: ZipListT m a -> ZipListT m a
$clog :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log :: ZipListT m a -> ZipListT m a
$csqrt :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
sqrt :: ZipListT m a -> ZipListT m a
$c** :: 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
$clogBase :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
logBase :: ZipListT m a -> ZipListT m a -> ZipListT m a
$csin :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
sin :: ZipListT m a -> ZipListT m a
$ccos :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
cos :: ZipListT m a -> ZipListT m a
$ctan :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
tan :: ZipListT m a -> ZipListT m a
$casin :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
asin :: ZipListT m a -> ZipListT m a
$cacos :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
acos :: ZipListT m a -> ZipListT m a
$catan :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
atan :: ZipListT m a -> ZipListT m a
$csinh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
sinh :: ZipListT m a -> ZipListT m a
$ccosh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
cosh :: ZipListT m a -> ZipListT m a
$ctanh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
tanh :: ZipListT m a -> ZipListT m a
$casinh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
asinh :: ZipListT m a -> ZipListT m a
$cacosh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
acosh :: ZipListT m a -> ZipListT m a
$catanh :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
atanh :: ZipListT m a -> ZipListT m a
$clog1p :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log1p :: ZipListT m a -> ZipListT m a
$cexpm1 :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
expm1 :: ZipListT m a -> ZipListT m a
$clog1pexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log1pexp :: ZipListT m a -> ZipListT m a
$clog1mexp :: forall (m :: * -> *) a.
(Monad m, Floating a) =>
ZipListT m a -> ZipListT m a
log1mexp :: ZipListT m a -> ZipListT m a
Floating, Num (ZipListT m a)
Num (ZipListT m a) =>
(ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (Rational -> ZipListT m a)
-> Fractional (ZipListT m a)
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
$c/ :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
/ :: ZipListT m a -> ZipListT m a -> ZipListT m a
$crecip :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
ZipListT m a -> ZipListT m a
recip :: ZipListT m a -> ZipListT m a
$cfromRational :: forall (m :: * -> *) a.
(Monad m, Fractional a) =>
Rational -> ZipListT m a
fromRational :: Rational -> ZipListT m a
Fractional, Integer -> ZipListT m a
ZipListT m a -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
(ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (ZipListT m a -> ZipListT m a)
-> (Integer -> ZipListT m a)
-> Num (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
$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
* :: ZipListT m a -> ZipListT m a -> ZipListT m a
$cnegate :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
negate :: ZipListT m a -> ZipListT m a
$cabs :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
abs :: ZipListT m a -> ZipListT m a
$csignum :: forall (m :: * -> *) a.
(Monad m, Num a) =>
ZipListT m a -> ZipListT m a
signum :: ZipListT m a -> ZipListT m a
$cfromInteger :: forall (m :: * -> *) a. (Monad m, Num a) => Integer -> ZipListT m a
fromInteger :: Integer -> ZipListT m a
Num, NonEmpty (ZipListT m a) -> ZipListT m a
ZipListT m a -> ZipListT m a -> ZipListT m a
(ZipListT m a -> ZipListT m a -> ZipListT m a)
-> (NonEmpty (ZipListT m a) -> ZipListT m a)
-> (forall b. Integral b => b -> ZipListT m a -> ZipListT m a)
-> Semigroup (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
$c<> :: forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
<> :: ZipListT m a -> ZipListT m a -> ZipListT m a
$csconcat :: forall (m :: * -> *) a.
(Monad m, Semigroup a) =>
NonEmpty (ZipListT m a) -> ZipListT m a
sconcat :: NonEmpty (ZipListT m a) -> ZipListT m a
$cstimes :: 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
Semigroup, Semigroup (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] -> ZipListT m a)
-> Monoid (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
$cmempty :: forall (m :: * -> *) a. (Monad m, Monoid a) => ZipListT m a
mempty :: ZipListT m a
$cmappend :: forall (m :: * -> *) a.
(Monad m, Monoid a) =>
ZipListT m a -> ZipListT m a -> ZipListT m a
mappend :: ZipListT m a -> ZipListT m a -> ZipListT m a
$cmconcat :: forall (m :: * -> *) a.
(Monad m, Monoid a) =>
[ZipListT m a] -> ZipListT m a
mconcat :: [ZipListT m a] -> ZipListT m a
Monoid)
instance Monad m => Applicative (ZipListT m) where
pure :: forall a. a -> ZipListT m a
pure a
x = ListT m a -> ZipListT m a
forall (m :: * -> *) a. ListT m a -> ZipListT m a
ZipListT ListT m a
go
where
#if MIN_VERSION_base(4,8,0)
go :: ListT m a
go = m (Step m a) -> ListT m a
forall (m :: * -> *) a. m (Step m a) -> ListT m a
ListT (Step m a -> m (Step m a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> ListT m a -> Step m a
forall (m :: * -> *) a. a -> ListT m a -> Step m a
Cons a
x ListT m a
go))
#else
go = ListT (return (Cons x go))
#endif
ZipListT ListT m (a -> b)
fs <*> :: forall a b. ZipListT m (a -> b) -> ZipListT m a -> ZipListT m b
<*> ZipListT ListT m a
xs = ListT m b -> ZipListT m b
forall (m :: * -> *) a. ListT m a -> ZipListT m a
ZipListT (((a -> b, a) -> b) -> ListT m (a -> b, a) -> ListT m b
forall a b. (a -> b) -> ListT m a -> ListT m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((a -> b) -> a -> b) -> (a -> b, a) -> b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
($)) (ListT m (a -> b) -> ListT m a -> ListT m (a -> b, a)
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))