Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Control/Applicative/Backwards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,17 @@ instance (Contravariant f) => Contravariant (Backwards f) where
contramap f = Backwards . contramap f . forwards
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Applicative f) => Semigroup (Backwards f a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Applicative f) => Monoid (Backwards f a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif
14 changes: 14 additions & 0 deletions Control/Applicative/Lift.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ instance (Foldable1 f) => Foldable1 (Lift f) where
{-# INLINE foldMap1 #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Applicative f) => Semigroup (Lift f a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Applicative f) => Monoid (Lift f a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Projection to the other functor.
unLift :: (Applicative f) => Lift f a -> f a
unLift (Pure x) = pure x
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Accum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ instance (Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m) where
liftIO = lift . liftIO
{-# INLINE liftIO #-}

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monoid w, Monad m) => Semigroup (AccumT w m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monoid w, Monad m) => Monoid (AccumT w m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | @'look'@ is an action that fetches all the previously accumulated output.
look :: (Monoid w, Monad m) => AccumT w m w
look = AccumT $ \ w -> return (w, mempty)
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Cont.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ instance (MonadIO m) => MonadIO (ContT r m) where
liftIO = lift . liftIO
{-# INLINE liftIO #-}

#if MIN_VERSION_base(4,9,0)
instance Semigroup a => Semigroup (ContT r m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance Monoid a => Monoid (ContT r m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | @callCC@ (call-with-current-continuation) calls its argument
-- function, passing it the current continuation. It provides
-- an escape continuation mechanism for use with continuation
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Except.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ instance Contravariant m => Contravariant (ExceptT e m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (ExceptT e m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (ExceptT e m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Signal an exception value @e@.
--
-- * @'runExceptT' ('throwE' e) = 'return' ('Left' e)@
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Identity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ instance (Contravariant f) => Contravariant (IdentityT f) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Applicative m) => Semigroup (IdentityT m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Applicative m) => Monoid (IdentityT m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Lift a unary operation to the new monad.
mapIdentityT :: (m a -> n b) -> IdentityT m a -> IdentityT n b
mapIdentityT f = IdentityT . f . runIdentityT
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Maybe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ instance Contravariant m => Contravariant (MaybeT m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (MaybeT m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (MaybeT m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Lift a @callCC@ operation to the new monad.
liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b
liftCallCC callCC f =
Expand Down
15 changes: 15 additions & 0 deletions Control/Monad/Trans/RWS/CPS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ instance MonadTrans (RWST r w s) where
instance (MonadIO m) => MonadIO (RWST r w s m) where
liftIO = lift . liftIO
{-# INLINE liftIO #-}

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (RWST r w s m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (RWST r w s m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- ---------------------------------------------------------------------------
-- Reader operations

Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/RWS/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ instance Contravariant m => Contravariant (RWST r w s m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monoid w, Monad m) => Semigroup (RWST r w s m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monoid w, Monad m) => Monoid (RWST r w s m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- ---------------------------------------------------------------------------
-- Reader operations

Expand Down
10 changes: 10 additions & 0 deletions Control/Monad/Trans/RWS/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ instance Contravariant m => Contravariant (RWST r w s m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monoid w, Monad m) => Semigroup (RWST r w s m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}

instance (Monoid a, Monoid w, Monad m) => Monoid (RWST r w s m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#endif

-- ---------------------------------------------------------------------------
-- Reader operations

Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Reader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ instance Contravariant m => Contravariant (ReaderT r m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Applicative m) => Semigroup (ReaderT r m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Applicative m) => Monoid (ReaderT r m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

liftReaderT :: m a -> ReaderT r m a
liftReaderT m = ReaderT (const m)
{-# INLINE liftReaderT #-}
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Select.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ instance (MonadIO m) => MonadIO (SelectT r m) where
liftIO = lift . liftIO
{-# INLINE liftIO #-}

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (SelectT r m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (SelectT r m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Convert a selection computation to a continuation-passing computation.
selectToContT :: (Monad m) => SelectT r m a -> ContT r m a
selectToContT (SelectT g) = ContT $ \ k -> g k >>= k
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/State/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ instance Contravariant m => Contravariant (StateT s m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (StateT s m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (StateT s m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | Fetch the current value of the state within the monad.
get :: (Monad m) => StateT s m s
get = state $ \ s -> (s, s)
Expand Down
10 changes: 10 additions & 0 deletions Control/Monad/Trans/State/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ instance Contravariant m => Contravariant (StateT s m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (StateT s m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}

instance (Monoid a, Monad m) => Monoid (StateT s m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#endif

-- | Fetch the current value of the state within the monad.
get :: (Monad m) => StateT s m s
get = state $ \ s -> (s, s)
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Writer/CPS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,20 @@ instance (MonadIO m) => MonadIO (WriterT w m) where
liftIO = lift . liftIO
{-# INLINE liftIO #-}

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monad m) => Semigroup (WriterT w m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monad m) => Monoid (WriterT w m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | @'tell' w@ is an action that produces the output @w@.
tell :: (Monoid w, Monad m) => w -> WriterT w m ()
tell w = writer ((), w)
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Writer/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,20 @@ instance Contravariant m => Contravariant (WriterT w m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monoid w, Applicative m) => Semigroup (WriterT w m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monoid w, Applicative m) => Monoid (WriterT w m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | @'tell' w@ is an action that produces the output @w@.
tell :: (Monad m) => w -> WriterT w m ()
tell w = writer ((), w)
Expand Down
14 changes: 14 additions & 0 deletions Control/Monad/Trans/Writer/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ instance Contravariant m => Contravariant (WriterT w m) where
{-# INLINE contramap #-}
#endif

#if MIN_VERSION_base(4,9,0)
instance (Semigroup a, Monoid w, Applicative m) => Semigroup (WriterT w m a) where
ma <> mb = (<>) <$> ma <*> mb
{-# INLINE (<>) #-}
#endif

instance (Monoid a, Monoid w, Applicative m) => Monoid (WriterT w m a) where
mempty = pure mempty
{-# INLINE mempty #-}
#if !MIN_VERSION_base(4,11,0)
ma `mappend` mb = (<>) <$> ma <*> mb
{-# INLINE mappend #-}
#endif

-- | @'tell' w@ is an action that produces the output @w@.
tell :: (Monad m) => w -> WriterT w m ()
tell w = writer ((), w)
Expand Down
Loading