Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Reexporting useful monadic stuff.
Synopsis
- module Relude.Monad.Reexport
- module Relude.Monad.Maybe
- module Relude.Monad.Either
- module Relude.Monad.Trans
- chainedTo :: Monad m => (a -> m b) -> m a -> m b
- infinitely :: Applicative f => f a -> f Void
Documentation
module Relude.Monad.Reexport
Reexports functions to work with different monads.
module Relude.Monad.Maybe
Provided new combinators to work with Maybe
data type.
module Relude.Monad.Either
Provided new combinators to work with Either
data type.
module Relude.Monad.Trans
Monad transformers functions and combinators.
chainedTo :: Monad m => (a -> m b) -> m a -> m b Source #
For chaining monadic operations in forward applications using (&)
Named version of =<<
.
>>>
Just [ 1 :: Int ] & chainedTo (viaNonEmpty head)
Just 1>>>
Nothing & chainedTo (viaNonEmpty head)
Nothing
Since: 0.5.0
infinitely :: Applicative f => f a -> f Void Source #
Repeat a monadic action indefinitely.
This is a more type safe version of forever
, which has a convenient
but unsafe type.
Consider the following two examples. In the getIntForever
functions, it
falsely expects Int
as the result of the forever
function. But it would need
to wait *forever* to get that, and this mistake won't be caught by the type
system and compiler:
getIntForever :: IO Int getIntForever = do i <- forever $ do ... pure i
In contrast, using infinitely
instead of forever
in foo
is a type error.
Since: 1.0.0.0