Copyright | (c) Donnacha Oisín Kidney 2021 |
---|---|
Maintainer | mail@doisinkidney.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
A simple re-implementation of the list monad transformer, for use by the heap monad.
Synopsis
- newtype ListT m a = ListT {}
- data ListCons a b
- unfoldrM :: Functor m => (b -> m (Maybe (a, b))) -> b -> ListT m a
- cons :: Applicative m => a -> ListT m a -> ListT m a
- nil :: Applicative m => ListT m a
- fromListT :: Applicative m => [a] -> ListT m a
- toListT :: Monad m => ListT m a -> m [a]
- foldListT :: ((ListCons a (ListT m a) -> c) -> m (ListCons a (ListT m a)) -> b) -> (a -> b -> c) -> c -> ListT m a -> b
- catMaybesT :: Monad m => (a -> Maybe b) -> ListT m a -> ListT m b
- listMmap :: Functor m => (m (ListCons a (ListT n b)) -> n (ListCons b (ListT n b))) -> ListT m a -> ListT n b
- scanl1M :: Functor m => (a -> a -> a) -> ListT m a -> ListT m a
Type Definition
A list monad transformer, "done right".
Instances
MonadTrans ListT Source # | |
Defined in Control.Monad.Heap.List | |
MonadWriter w m => MonadWriter w (ListT m) Source # | |
MonadState s m => MonadState s (ListT m) Source # | |
MonadReader r m => MonadReader r (ListT m) Source # | |
MonadError e m => MonadError e (ListT m) Source # | |
Defined in Control.Monad.Heap.List throwError :: e -> ListT m a # catchError :: ListT m a -> (e -> ListT m a) -> ListT m a # | |
Monad m => Monad (ListT m) Source # | |
Functor m => Functor (ListT m) Source # | |
Monad m => Applicative (ListT m) Source # | |
Foldable m => Foldable (ListT m) Source # | |
Defined in Control.Monad.Heap.List fold :: Monoid m0 => ListT m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> ListT m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> ListT m a -> m0 # foldr :: (a -> b -> b) -> b -> ListT m a -> b # foldr' :: (a -> b -> b) -> b -> ListT m a -> b # foldl :: (b -> a -> b) -> b -> ListT m a -> b # foldl' :: (b -> a -> b) -> b -> ListT m a -> b # foldr1 :: (a -> a -> a) -> ListT m a -> a # foldl1 :: (a -> a -> a) -> ListT m a -> a # elem :: Eq a => a -> ListT m a -> Bool # maximum :: Ord a => ListT m a -> a # minimum :: Ord a => ListT m a -> a # | |
Traversable m => Traversable (ListT m) Source # | |
Arbitrary1 m => Arbitrary1 (ListT m) Source # | |
Defined in Control.Monad.Heap.List liftArbitrary :: Gen a -> Gen (ListT m a) # liftShrink :: (a -> [a]) -> ListT m a -> [ListT m a] # | |
Monad m => Alternative (ListT m) Source # | |
Monad m => MonadPlus (ListT m) Source # | |
MonadCont m => MonadCont (ListT m) Source # | |
m ~ Identity => IsList (ListT m a) Source # | |
(forall x. Eq x => Eq (m x), Eq a) => Eq (ListT m a) Source # | |
(forall x. Data x => Data (m x), Typeable m, Data a) => Data (ListT m a) Source # | |
Defined in Control.Monad.Heap.List gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListT m a -> c (ListT m a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ListT m a) # toConstr :: ListT m a -> Constr # dataTypeOf :: ListT m a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ListT m a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListT m a)) # gmapT :: (forall b. Data b => b -> b) -> ListT m a -> ListT m a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListT m a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListT m a -> r # gmapQ :: (forall d. Data d => d -> u) -> ListT m a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ListT m a -> u # gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> ListT m a -> m0 (ListT m a) # gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> ListT m a -> m0 (ListT m a) # gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> ListT m a -> m0 (ListT m a) # | |
(forall x. Ord x => Ord (m x), Eq (ListT m a), Ord a) => Ord (ListT m a) Source # | |
Defined in Control.Monad.Heap.List | |
(forall x. Read x => Read (m x), Read a) => Read (ListT m a) Source # | |
(forall x. Show x => Show (m x), Show a) => Show (ListT m a) Source # | |
Generic (ListT m a) Source # | |
Monad m => Semigroup (ListT m a) Source # | |
Monad m => Monoid (ListT m a) Source # | |
(Arbitrary1 m, Arbitrary a) => Arbitrary (ListT m a) Source # | |
(forall x. NFData x => NFData (m x), NFData a) => NFData (ListT m a) Source # | |
Defined in Control.Monad.Heap.List | |
type Rep (ListT m a) Source # | |
Defined in Control.Monad.Heap.List | |
type Item (ListT m a) Source # | |
Defined in Control.Monad.Heap.List |
The list constructor.
Instances
Arbitrary2 ListCons Source # | |
Defined in Control.Monad.Heap.List liftArbitrary2 :: Gen a -> Gen b -> Gen (ListCons a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> ListCons a b -> [ListCons a b] # | |
Bitraversable ListCons Source # | |
Defined in Control.Monad.Heap.List bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> ListCons a b -> f (ListCons c d) # | |
Bifoldable ListCons Source # | |
Bifunctor ListCons Source # | |
Functor (ListCons a) Source # | |
Foldable (ListCons a) Source # | |
Defined in Control.Monad.Heap.List fold :: Monoid m => ListCons a m -> m # foldMap :: Monoid m => (a0 -> m) -> ListCons a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> ListCons a a0 -> m # foldr :: (a0 -> b -> b) -> b -> ListCons a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> ListCons a a0 -> b # foldl :: (b -> a0 -> b) -> b -> ListCons a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> ListCons a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> ListCons a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> ListCons a a0 -> a0 # toList :: ListCons a a0 -> [a0] # null :: ListCons a a0 -> Bool # length :: ListCons a a0 -> Int # elem :: Eq a0 => a0 -> ListCons a a0 -> Bool # maximum :: Ord a0 => ListCons a a0 -> a0 # minimum :: Ord a0 => ListCons a a0 -> a0 # | |
Traversable (ListCons a) Source # | |
Defined in Control.Monad.Heap.List | |
Arbitrary a => Arbitrary1 (ListCons a) Source # | |
Defined in Control.Monad.Heap.List liftArbitrary :: Gen a0 -> Gen (ListCons a a0) # liftShrink :: (a0 -> [a0]) -> ListCons a a0 -> [ListCons a a0] # | |
Generic1 (ListCons a :: Type -> Type) Source # | |
(Eq a, Eq b) => Eq (ListCons a b) Source # | |
(Data a, Data b) => Data (ListCons a b) Source # | |
Defined in Control.Monad.Heap.List gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> ListCons a b -> c (ListCons a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ListCons a b) # toConstr :: ListCons a b -> Constr # dataTypeOf :: ListCons a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ListCons a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListCons a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> ListCons a b -> ListCons a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListCons a b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListCons a b -> r # gmapQ :: (forall d. Data d => d -> u) -> ListCons a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ListCons a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListCons a b -> m (ListCons a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListCons a b -> m (ListCons a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListCons a b -> m (ListCons a b) # | |
(Ord a, Ord b) => Ord (ListCons a b) Source # | |
Defined in Control.Monad.Heap.List | |
(Read a, Read b) => Read (ListCons a b) Source # | |
(Show a, Show b) => Show (ListCons a b) Source # | |
Generic (ListCons a b) Source # | |
(Arbitrary a, Arbitrary b) => Arbitrary (ListCons a b) Source # | |
(NFData a, NFData b) => NFData (ListCons a b) Source # | |
Defined in Control.Monad.Heap.List | |
type Rep1 (ListCons a :: Type -> Type) Source # | |
Defined in Control.Monad.Heap.List type Rep1 (ListCons a :: Type -> Type) = D1 ('MetaData "ListCons" "Control.Monad.Heap.List" "monus-weighted-search-0.2.0.0-inplace" 'False) (C1 ('MetaCons "Nil" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons ":-" ('InfixI 'RightAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1)) | |
type Rep (ListCons a b) Source # | |
Defined in Control.Monad.Heap.List type Rep (ListCons a b) = D1 ('MetaData "ListCons" "Control.Monad.Heap.List" "monus-weighted-search-0.2.0.0-inplace" 'False) (C1 ('MetaCons "Nil" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons ":-" ('InfixI 'RightAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b))) |
Building the list
unfoldrM :: Functor m => (b -> m (Maybe (a, b))) -> b -> ListT m a Source #
Unfold, monadically, a list from a seed.
nil :: Applicative m => ListT m a Source #
fromListT :: Applicative m => [a] -> ListT m a Source #
Running the list
toListT :: Monad m => ListT m a -> m [a] Source #
Flatten all of the effects in the list and collect the results.
foldListT :: ((ListCons a (ListT m a) -> c) -> m (ListCons a (ListT m a)) -> b) -> (a -> b -> c) -> c -> ListT m a -> b Source #
Transforming lists
catMaybesT :: Monad m => (a -> Maybe b) -> ListT m a -> ListT m b Source #
Filter the list. An analogue of mapMaybe on lists.