-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A monad and monad transformer for pushing things onto a stack very fast. -- -- This library gives you a monad that lets you push things onto a stack -- very quickly. You get things off the stack when you run the monad. -- Under the hood, this uses mutable vectors. I've also included a monad -- transformer using the STMonadTrans library that does the same thing as -- a transformer, but it's probably very unsafe. @package FastPush @version 0.1.0.2 module Control.Monad.Push.Class class Monad m => MonadPush a m -- | Push an item onto the stack push :: MonadPush a m => a -> m () module Control.Monad.Trans.Push -- | The internal return type of a push action. The Int value is the new -- vector used length. data Res a Res :: !Int -> !a -> Res a -- | A monad transformer that lets you push things onto a stack. This is -- probably super unsafe; see the docs for Control.Monad.ST.Trans. newtype PushT v p m a PushT :: (forall s. Int -> (STRef s (v s p)) -> (STT s m (Res a))) -> PushT v p m a -- | This seems *highly* questionable, but appears to get the job done. liftST :: Applicative m => ST s a -> STT s m a -- | Run the monad transformer. runPushT :: (Monad m, Vector v p) => PushT (Mutable v) p m a -> m (a, v p) -- | Specialized to Unboxed vectors. runPushTU :: forall p a m. (Unbox p, Monad m) => PushT (MVector) p m a -> m (a, Vector p) -- | Specialized to Storable vectors. -- -- Specialized to standard Boxed vectors. runPushTB :: forall p a m. Monad m => PushT (MVector) p m a -> m (a, Vector p) runPushTS :: forall p a m. (Storable p, Monad m) => PushT (MVector) p m a -> m (a, Vector p) instance GHC.Base.Functor Control.Monad.Trans.Push.Res instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Push.PushT v p m) instance GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Trans.Push.PushT v p m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Push.PushT v p m) instance (GHC.Base.Monad m, Data.Vector.Generic.Mutable.Base.MVector v p) => Control.Monad.Push.Class.MonadPush p (Control.Monad.Trans.Push.PushT v p m) module Control.Monad.Push -- | The internal return type of a push action. The Int value is the new -- vector used length. data Res a Res :: !Int -> !a -> Res a -- | A monad that lets you push things onto a stack. newtype Push v p a Push :: (forall s. Int -> (STRef s (v s p)) -> (ST s (Res a))) -> Push v p a -- | Run the Push monad. Get the return value and the output stack. runPush :: Vector v p => Push (Mutable v) p a -> (a, v p) -- | Specialized to Unboxed vectors. runPushU :: forall p a. Unbox p => Push (MVector) p a -> (a, Vector p) -- | Specialized to standard Boxed vectors. runPushB :: forall p a. Push (MVector) p a -> (a, Vector p) -- | Specialized to Storable vectors. runPushS :: forall p a. Storable p => Push (MVector) p a -> (a, Vector p) instance GHC.Base.Functor (Control.Monad.Push.Push v p) instance GHC.Base.Functor Control.Monad.Push.Res instance GHC.Base.Applicative (Control.Monad.Push.Push v p) instance GHC.Base.Monad (Control.Monad.Push.Push v p) instance Data.Vector.Generic.Mutable.Base.MVector v p => Control.Monad.Push.Class.MonadPush p (Control.Monad.Push.Push v p) module Control.Monad.Push.Example -- | A simple test routine, generic over choice of MonadPush instance. test :: MonadPush Int m => m () -- | Using the pure Push monad testMonad :: IO () -- | Using PushT over IO testTransformer :: IO ()