-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A backtracking logic-programming monad with asymptotic improvements to msplit -- -- Adapted from the paper http://okmij.org/ftp/Haskell/zseq.pdf by -- Atze van der Ploeg and Oleg Kiselyov @package logict-sequence @version 0.2 -- | It's safe to coerce to Any as long as you don't coerce -- back. We define our own Any instead of using the one in -- GHC.Exts directly to ensure that this module doesn't clash with -- one making the opposite assumption. We use a newtype rather than a -- closed type family with no instances because the latter weren't -- supported until 8.0. module Control.Monad.Logic.Sequence.Internal.Any data Any -- | Convert a list of anything to a list of Any. toAnyList :: [a] -> [Any] -- | A sequence, a queue, with worst case constant time: |>, -- and viewl. -- -- Based on: "Simple and Efficient Purely Functional Queues and Deques", -- Chris Okasaki, Journal of Functional Programming 1995 module Control.Monad.Logic.Sequence.Internal.ScheduledQueue -- | A scheduled Banker's Queue, as described by Okasaki. data Queue a instance GHC.Base.Functor Control.Monad.Logic.Sequence.Internal.ScheduledQueue.SL instance GHC.Base.Functor Control.Monad.Logic.Sequence.Internal.ScheduledQueue.Queue instance Data.SequenceClass.Sequence Control.Monad.Logic.Sequence.Internal.ScheduledQueue.Queue instance Data.Foldable.Foldable Control.Monad.Logic.Sequence.Internal.ScheduledQueue.Queue instance Data.Traversable.Traversable Control.Monad.Logic.Sequence.Internal.ScheduledQueue.Queue module Control.Monad.Logic.Sequence.Internal.Queue -- | 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. data Queue a instance Data.Traversable.Traversable Control.Monad.Logic.Sequence.Internal.Queue.Queue instance Data.Foldable.Foldable Control.Monad.Logic.Sequence.Internal.Queue.Queue instance GHC.Base.Functor Control.Monad.Logic.Sequence.Internal.Queue.Queue instance Data.SequenceClass.Sequence Control.Monad.Logic.Sequence.Internal.Queue.Queue instance GHC.Base.Semigroup (Control.Monad.Logic.Sequence.Internal.Queue.Queue a) instance GHC.Base.Monoid (Control.Monad.Logic.Sequence.Internal.Queue.Queue a) -- | 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. module Control.Monad.Logic.Sequence.Internal -- | 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. newtype SeqT m a SeqT :: Queue (m (ViewT m a)) -> SeqT m a pattern MkSeqT :: Monad m => m (ViewT m a) -> SeqT m a -- | 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. type Seq = SeqT Identity pattern MkSeq :: View a -> Seq a getSeq :: Seq a -> View a -- | A view of the front end of a SeqT. data ViewT m a Empty :: ViewT m a (:<) :: a -> SeqT m a -> ViewT m a infixl 5 :< type View = ViewT Identity -- | A catamorphism for ViewTs viewT :: b -> (a -> SeqT m a -> b) -> ViewT m a -> b -- | A catamorphism for Views. Note that this is just a -- type-restricted version of viewT. 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 -- | Perform all the actions in a SeqT and gather the results. observeAllT :: Monad m => SeqT m a -> m [a] -- | Get all the results in a Seq. observeAll :: Seq a -> [a] -- | observeManyT n s performs actions in s until it -- produces n results or terminates. All the gathered results -- are returned. observeManyT :: Monad m => Int -> SeqT m a -> m [a] -- | observeMany n s gets up to n results from a -- Seq. observeMany :: Int -> Seq a -> [a] -- | Perform actions in a SeqT until one of them produces a result. -- Returns Nothing if there are no results. observeT :: Monad m => SeqT m a -> m (Maybe a) -- | Get the first result in a Seq, if there is one. observe :: Seq a -> Maybe a -- | Convert SeqT m a to t m a when t is -- some other logic monad transformer. fromSeqT :: (Monad m, Monad (t m), MonadTrans t, Alternative (t m)) => SeqT m a -> t m a -- | This function is the implementation of hoist for SeqT. -- The passed function is required to be a monad morphism. hoistPre :: Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | A version of hoist that uses the Monad instance for -- n rather than for m. Like hoist, the passed -- function is required to be a monad morphism. hoistPost :: Monad n => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | A version of hoist that works for arbitrary functions, rather -- than just monad morphisms. hoistPreUnexposed :: forall m n a. Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | A version of hoistPost that works for arbitrary functions, -- rather than just monad morphisms. This should be preferred when the -- Monad instance for n is less expensive than that for -- m. hoistPostUnexposed :: forall m n a. (Monad m, Monad n) => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | Convert SeqT m a to LogicT m a. -- --
--   toLogicT = fromSeqT
--   
toLogicT :: Monad m => SeqT m a -> LogicT m a fromLogicT :: Monad m => LogicT m a -> SeqT m a -- |
--   cons a s = pure a | s
--   
cons :: Monad m => a -> SeqT m a -> SeqT m a -- |
--   consM m s = lift m | s
--   
consM :: Monad m => m a -> SeqT m a -> SeqT m a -- |
--   choose = foldr (a s -> pure a | s) empty
--   
-- --
--   choose :: Monad m => [a] -> SeqT m a
--   
choose :: (Foldable t, Monad m) => t a -> SeqT m a -- |
--   chooseM = foldr (ma s -> lift ma | s) empty
--   
-- --
--   chooseM :: Monad m => [m a] -> SeqT m a
--   
chooseM :: (Foldable t, Monad m) => t (m a) -> SeqT m a instance GHC.Generics.Generic (Control.Monad.Logic.Sequence.Internal.ViewT m a) instance (GHC.Show.Show a, GHC.Show.Show (Control.Monad.Logic.Sequence.Internal.SeqT m a)) => GHC.Show.Show (Control.Monad.Logic.Sequence.Internal.ViewT m a) instance (GHC.Read.Read a, GHC.Read.Read (Control.Monad.Logic.Sequence.Internal.SeqT m a)) => GHC.Read.Read (Control.Monad.Logic.Sequence.Internal.ViewT m a) instance (GHC.Classes.Eq a, GHC.Classes.Eq (Control.Monad.Logic.Sequence.Internal.SeqT m a)) => GHC.Classes.Eq (Control.Monad.Logic.Sequence.Internal.ViewT m a) instance (GHC.Classes.Ord a, GHC.Classes.Ord (Control.Monad.Logic.Sequence.Internal.SeqT m a)) => GHC.Classes.Ord (Control.Monad.Logic.Sequence.Internal.ViewT m a) instance GHC.Base.Monad m => GHC.Base.Functor (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (GHC.Base.Monad m, Data.Foldable.Foldable m) => Data.Foldable.Foldable (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (GHC.Base.Monad m, Data.Traversable.Traversable m) => Data.Traversable.Traversable (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (Data.Functor.Classes.Eq1 m, GHC.Base.Monad m) => Data.Functor.Classes.Eq1 (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (Data.Functor.Classes.Ord1 m, GHC.Base.Monad m) => Data.Functor.Classes.Ord1 (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (Data.Functor.Classes.Show1 m, GHC.Base.Monad m) => Data.Functor.Classes.Show1 (Control.Monad.Logic.Sequence.Internal.ViewT m) instance (GHC.Show.Show (m (Control.Monad.Logic.Sequence.Internal.ViewT m a)), GHC.Base.Monad m) => GHC.Show.Show (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance GHC.Read.Read (m (Control.Monad.Logic.Sequence.Internal.ViewT m a)) => GHC.Read.Read (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance (GHC.Classes.Eq a, GHC.Classes.Eq (m (Control.Monad.Logic.Sequence.Internal.ViewT m a)), GHC.Base.Monad m) => GHC.Classes.Eq (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance (GHC.Classes.Ord a, GHC.Classes.Ord (m (Control.Monad.Logic.Sequence.Internal.ViewT m a)), GHC.Base.Monad m) => GHC.Classes.Ord (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance (Data.Functor.Classes.Eq1 m, GHC.Base.Monad m) => Data.Functor.Classes.Eq1 (Control.Monad.Logic.Sequence.Internal.SeqT m) instance (Data.Functor.Classes.Ord1 m, GHC.Base.Monad m) => Data.Functor.Classes.Ord1 (Control.Monad.Logic.Sequence.Internal.SeqT m) instance (Data.Functor.Classes.Show1 m, GHC.Base.Monad m) => Data.Functor.Classes.Show1 (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.Functor (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.Alternative (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => Control.Monad.Fail.MonadFail (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.MonadPlus (Control.Monad.Logic.Sequence.Internal.SeqT m) instance GHC.Base.Monad m => GHC.Base.Semigroup (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance GHC.Base.Monad m => GHC.Base.Monoid (Control.Monad.Logic.Sequence.Internal.SeqT m a) instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Logic.Sequence.Internal.SeqT instance GHC.Base.Monad m => Control.Monad.Logic.Class.MonadLogic (Control.Monad.Logic.Sequence.Internal.SeqT m) instance (GHC.Base.Monad m, Data.Foldable.Foldable m) => Data.Foldable.Foldable (Control.Monad.Logic.Sequence.Internal.SeqT m) instance (GHC.Base.Monad m, Data.Traversable.Traversable m) => Data.Traversable.Traversable (Control.Monad.Logic.Sequence.Internal.SeqT m) instance Control.Monad.Morph.MFunctor Control.Monad.Logic.Sequence.Internal.SeqT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Logic.Sequence.Internal.SeqT m) instance Control.Monad.Reader.Class.MonadReader e m => Control.Monad.Reader.Class.MonadReader e (Control.Monad.Logic.Sequence.Internal.SeqT m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.Logic.Sequence.Internal.SeqT m) instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError e (Control.Monad.Logic.Sequence.Internal.SeqT m) instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Logic.Sequence.Internal.SeqT m) module Control.Monad.Logic.Sequence.Compat -- | Convert SeqT m a to t m a when t is -- some other logic monad transformer. fromSeqT :: (Monad m, Monad (t m), MonadTrans t, Alternative (t m)) => SeqT m a -> t m a -- | Convert SeqT m a to LogicT m a. -- --
--   toLogicT = fromSeqT
--   
toLogicT :: Monad m => SeqT m a -> LogicT m a fromLogicT :: Monad m => LogicT m a -> SeqT m a observeT :: MonadFail m => SeqT m a -> m a observe :: Seq a -> a module Control.Monad.Logic.Sequence -- | 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. data SeqT m a pattern MkSeqT :: Monad m => m (ViewT m a) -> SeqT m a -- | 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. type Seq = SeqT Identity pattern MkSeq :: View a -> Seq a getSeq :: Seq a -> View a -- | A view of the front end of a SeqT. data ViewT m a Empty :: ViewT m a (:<) :: a -> SeqT m a -> ViewT m a infixl 5 :< type View = ViewT Identity -- | A catamorphism for ViewTs viewT :: b -> (a -> SeqT m a -> b) -> ViewT m a -> b -- | A catamorphism for Views. Note that this is just a -- type-restricted version of viewT. 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 -- |
--   cons a s = pure a | s
--   
cons :: Monad m => a -> SeqT m a -> SeqT m a -- |
--   consM m s = lift m | s
--   
consM :: Monad m => m a -> SeqT m a -> SeqT m a -- |
--   choose = foldr (a s -> pure a | s) empty
--   
-- --
--   choose :: Monad m => [a] -> SeqT m a
--   
choose :: (Foldable t, Monad m) => t a -> SeqT m a -- |
--   chooseM = foldr (ma s -> lift ma | s) empty
--   
-- --
--   chooseM :: Monad m => [m a] -> SeqT m a
--   
chooseM :: (Foldable t, Monad m) => t (m a) -> SeqT m a -- | Perform all the actions in a SeqT and gather the results. observeAllT :: Monad m => SeqT m a -> m [a] -- | Get all the results in a Seq. observeAll :: Seq a -> [a] -- | observeManyT n s performs actions in s until it -- produces n results or terminates. All the gathered results -- are returned. observeManyT :: Monad m => Int -> SeqT m a -> m [a] -- | observeMany n s gets up to n results from a -- Seq. observeMany :: Int -> Seq a -> [a] -- | Perform actions in a SeqT until one of them produces a result. -- Returns Nothing if there are no results. observeT :: Monad m => SeqT m a -> m (Maybe a) -- | Get the first result in a Seq, if there is one. observe :: Seq a -> Maybe a -- | This module provides functions for changing the underlying monad of a -- SeqT, just like Control.Monad.Morph.hoist. -- -- The functions with the word "Pre" in their names lean on the -- Monad instance of the original monad. The ones with the word -- "Post" in their names lean on the Monad instance of the target -- monad. The ones with the word "Unexposed" in their names are -- reasonably well-behaved when the passed function is not a monad -- morphism (as described in the Control.Monad.Morph -- documentation). The others are typically a little more efficient, but -- may behave strangely when passed non-monad-morphisms. In particular, -- if f is not a monad morphism, and s1 == s2, we do -- not even guarantee that hoistPre f s1 == hoistPre f -- s2. module Control.Monad.Logic.Sequence.Morph -- | A version of hoist that works for arbitrary functions, rather -- than just monad morphisms. hoistPreUnexposed :: forall m n a. Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | A version of hoist that uses the Monad instance for -- n rather than for m. Like hoist, the passed -- function is required to be a monad morphism. hoistPost :: Monad n => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | A version of hoistPost that works for arbitrary functions, -- rather than just monad morphisms. This should be preferred when the -- Monad instance for n is less expensive than that for -- m. hoistPostUnexposed :: forall m n a. (Monad m, Monad n) => (forall x. m x -> n x) -> SeqT m a -> SeqT n a -- | This function is the implementation of hoist for SeqT. -- The passed function is required to be a monad morphism. hoistPre :: Monad m => (forall x. m x -> n x) -> SeqT m a -> SeqT n a