Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Based on the LogicT improvements in the paper, Reflection without Remorse. Code is based on the code provided in: https://github.com/atzeus/reflectionwithoutremorse
Note: that code is provided under an MIT license, so we use that as well.
Synopsis
- newtype SeqT m a where
- type Seq = SeqT Identity
- pattern MkSeq :: View a -> Seq a
- getSeq :: Seq a -> View a
- data ViewT m a
- type View = ViewT Identity
- viewT :: b -> (a -> SeqT m a -> b) -> ViewT m a -> b
- view :: b -> (a -> Seq a -> b) -> View a -> b
- toViewT :: Monad m => SeqT m a -> m (ViewT m a)
- toView :: forall a. Seq a -> View a
- fromViewT :: m (ViewT m a) -> SeqT m a
- fromView :: forall a. View a -> Seq a
- observeAllT :: Monad m => SeqT m a -> m [a]
- observeAll :: Seq a -> [a]
- observeManyT :: Monad m => Int -> SeqT m a -> m [a]
- observeMany :: Int -> Seq a -> [a]
- observeT :: Monad m => SeqT m a -> m (Maybe a)
- observe :: Seq a -> Maybe a
- fromSeqT :: (Monad m, Monad (t m), MonadTrans t, Alternative (t m)) => SeqT m a -> t m a
- hoistPre :: Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a
- hoistPost :: Monad n => (forall x. m x -> n x) -> SeqT m a -> SeqT n a
- hoistPreUnexposed :: forall m n a. Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a
- hoistPostUnexposed :: forall m n a. (Monad m, Monad n) => (forall x. m x -> n x) -> SeqT m a -> SeqT n a
- toLogicT :: Monad m => SeqT m a -> LogicT m a
- fromLogicT :: Monad m => LogicT m a -> SeqT m a
- cons :: Monad m => a -> SeqT m a -> SeqT m a
- consM :: Monad m => m a -> SeqT m a -> SeqT m a
- choose :: (Foldable t, Monad m) => t a -> SeqT m a
- chooseM :: (Foldable t, Monad m) => t (m a) -> SeqT m a
Documentation
An asymptotically efficient logic monad transformer. It is generally best to think of this as being defined
newtype SeqT m a =MkSeqT
{getSeqT
:: m (ViewT
m a) }
Using the MkSeqT
pattern synonym with getSeqT
, you can (almost) pretend
it's really defined this way! However, the real implementation is different,
so as to be more efficient in the face of deeply left-associated <|>
or
mplus
applications.
Instances
type Seq = SeqT Identity Source #
A specialization of SeqT
to the Identity
monad. You can
imagine that this is defined
newtype Seq a = MkSeq { getSeq :: ViewT Identity a }
Using the MkSeq
pattern synonym with getSeq
, you can pretend it's
really defined this way! However, the real implementation is different,
so as to be more efficient in the face of deeply left-associated <|>
or mplus
applications.
A view of the front end of a SeqT
.
Instances
observeAllT :: Monad m => SeqT m a -> m [a] Source #
Perform all the actions in a SeqT
and gather the results.
observeAll :: Seq a -> [a] Source #
Get all the results in a Seq
.
observeManyT :: Monad m => Int -> SeqT m a -> m [a] Source #
observeManyT n s
performs actions in s
until it produces
n
results or terminates. All the gathered results are returned.
fromSeqT :: (Monad m, Monad (t m), MonadTrans t, Alternative (t m)) => SeqT m a -> t m a Source #
Convert
to SeqT
m at m a
when t
is some other logic monad
transformer.
hoistPreUnexposed :: forall m n a. Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a Source #
A version of hoist
that works for arbitrary functions, rather
than just monad morphisms.
hoistPostUnexposed :: forall m n a. (Monad m, Monad n) => (forall x. m x -> n x) -> SeqT m a -> SeqT n a Source #