| Copyright | (c) 2022 Composewell Technologies |
|---|---|
| License | BSD-3-Clause |
| Maintainer | streamly@composewell.com |
| Stability | released |
| Portability | GHC |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Streamly.Data.Stream.MkType
Description
Template Haskell macros to create custom newtype wrappers for the Stream
type. See the examples below to create the standard stream types that were
available in streamly versions before 0.9.0.
To use this module, the following extensions must be enabled:
>>>:set -XStandaloneDeriving>>>:set -XTemplateHaskell>>>:set -XTypeFamilies>>>:set -XUndecidableInstances
Import this module unqualified to bring everything needed in scope without
having to import several other modules. Also, Streamly.Data.Stream or
Streamly.Data.Stream.Prelude must be imported as Stream.
>>>import Streamly.Data.Stream.MkType>>>import qualified Streamly.Data.Stream.Prelude as Stream
For AsyncT monad type with a concurrent cross product
bind:
>>>:{bind = flip (Stream.parConcatMap id) $(mkCrossType "AsyncT" "bind" True) :}
For WAsyncT monad type with a concurrent interleaved
bind:
>>>:{bind = flip (Stream.parConcatMap (Stream.interleaved True)) $(mkCrossType "WAsyncT" "bind" True) :}
For AheadT monad type with a concurrent ordered
cross product bind:
>>>:{bind = flip (Stream.parConcatMap (Stream.ordered True)) $(mkCrossType "AheadT" "bind" True) :}
For ParallelT monad type with an eager concurrent cross
product bind:
>>>:{parBind = flip (Stream.parConcatMap (Stream.eager True)) $(mkCrossType "ParallelT" "parBind" True) :}
For ZipSerialM serial zipping applicative type:
>>>:{zipApply = Stream.zipWith ($) $(mkZipType "ZipSerialM" "zipApply" False) :}
For ZipAsync concurrent zipping applicative type:
>>>:{parApply = Stream.parApply id $(mkZipType "ZipAsync" "parApply" True) :}
Instead of using these macros directly you could use the generated code as well. Use these macros in ghci to generate the required code and paste it in your package, you can customize the code as desired. See the docs of the macros below for examples about how to view the generated code. For example:
>>>bind = flip (Stream.parConcatMap id)>>>expr <- runQ (mkCrossType "AsyncT" "bind" True)
> putStrLn $ pprint expr
Synopsis
- mkZipType :: String -> String -> Bool -> Q [Dec]
- mkCrossType :: String -> String -> Bool -> Q [Dec]
- class Read a where
- class Monad m => MonadIO (m :: Type -> Type) where
- class Monad m => MonadThrow (m :: Type -> Type) where
- class Monad m => MonadReader r (m :: Type -> Type) | m -> r where
- class MonadTrans (t :: (Type -> Type) -> Type -> Type) where
- data Identity a
- class IsList l
- class IsString a
- ap :: Monad m => m (a -> b) -> m a -> m b
Imports for Examples
>>>:m>>>import Language.Haskell.TH>>>import qualified Streamly.Data.Stream.Prelude as Stream>>>import Streamly.Data.Stream.MkType
Template Haskell Macros
Arguments
| :: String | Name of the type |
| -> String | Function to use for (<*>) |
| -> Bool |
|
| -> Q [Dec] |
Create a type with a zip-like applicative.
>>>expr <- runQ (mkZipType "ZipStream" "zipApply" False)>>>putStrLn $ pprint exprnewtype ZipStream m a = ZipStream (Stream.Stream m a) deriving Foldable mkZipStream :: Stream.Stream m a -> ZipStream m a mkZipStream = ZipStream unZipStream :: ZipStream m a -> Stream.Stream m a unZipStream (ZipStream strm) = strm deriving instance IsList (ZipStream Identity a) deriving instance a ~ GHC.Types.Char => IsString (ZipStream Identity a) deriving instance GHC.Classes.Eq a => Eq (ZipStream Identity a) deriving instance GHC.Classes.Ord a => Ord (ZipStream Identity a) instance Show a => Show (ZipStream Identity a) where {{-# INLINE show #-}; show (ZipStream strm) = show strm} instance Read a => Read (ZipStream Identity a) where {{-# INLINE readPrec #-}; readPrec = fmap ZipStream readPrec} instance Monad m => Functor (ZipStream m) where {{-# INLINE fmap #-}; fmap f (ZipStream strm) = ZipStream (fmap f strm)} instance Monad m => Applicative (ZipStream m) where {{-# INLINE pure #-}; pure = ZipStream . Stream.repeat; {-# INLINE (<*>) #-}; (<*>) (ZipStream strm1) (ZipStream strm2) = ZipStream (zipApply strm1 strm2)}
Arguments
| :: String | Name of the type |
| -> String | Function to use for (>>=) |
| -> Bool |
|
| -> Q [Dec] |
Create a type with specific stream combination properties.
>>>expr <- runQ (mkCrossType "Parallel" "parBind" True)>>>putStrLn $ pprint exprnewtype Parallel m a = Parallel (Stream.Stream m a) mkParallel :: Stream.Stream m a -> Parallel m a mkParallel = Parallel unParallel :: Parallel m a -> Stream.Stream m a unParallel (Parallel strm) = strm instance Monad m => Functor (Parallel m) where {{-# INLINE fmap #-}; fmap f (Parallel strm) = Parallel (fmap f strm)} instance Stream.MonadAsync m => Monad (Parallel m) where {{-# INLINE (>>=) #-}; (>>=) (Parallel strm1) f = let f1 a = unParallel (f a) in Parallel (parBind strm1 f1)} instance Stream.MonadAsync m => Applicative (Parallel m) where {{-# INLINE pure #-}; pure = Parallel . Stream.fromPure; {-# INLINE (<*>) #-}; (<*>) = ap} instance (Monad (Parallel m), MonadIO m) => MonadIO (Parallel m) where {{-# INLINE liftIO #-}; liftIO = Parallel . (Stream.fromEffect . liftIO)} instance (Monad (Parallel m), MonadThrow m) => MonadThrow (Parallel m) where {{-# INLINE throwM #-}; throwM = Parallel . (Stream.fromEffect . throwM)}
Re-exports
Parsing of Strings, producing values.
Derived instances of Read make the following assumptions, which
derived instances of Show obey:
- If the constructor is defined to be an infix operator, then the
derived
Readinstance will parse only infix applications of the constructor (not the prefix form). - Associativity is not used to reduce the occurrence of parentheses, although precedence may be.
- If the constructor is defined using record syntax, the derived
Readwill parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Readinstance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Read in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where
readsPrec d r = readParen (d > app_prec)
(\r -> [(Leaf m,t) |
("Leaf",s) <- lex r,
(m,t) <- readsPrec (app_prec+1) s]) r
++ readParen (d > up_prec)
(\r -> [(u:^:v,w) |
(u,s) <- readsPrec (up_prec+1) r,
(":^:",t) <- lex s,
(v,w) <- readsPrec (up_prec+1) t]) r
where app_prec = 10
up_prec = 5Note that right-associativity of :^: is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where
readPrec = parens $ (prec app_prec $ do
Ident "Leaf" <- lexP
m <- step readPrec
return (Leaf m))
+++ (prec up_prec $ do
u <- step readPrec
Symbol ":^:" <- lexP
v <- step readPrec
return (u :^: v))
where app_prec = 10
up_prec = 5
readListPrec = readListPrecDefaultWhy do both readsPrec and readPrec exist, and why does GHC opt to
implement readPrec in derived Read instances instead of readsPrec?
The reason is that readsPrec is based on the ReadS type, and although
ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient
parser data structure.
readPrec, on the other hand, is based on a much more efficient ReadPrec
datatype (a.k.a "new-style parsers"), but its definition relies on the use
of the RankNTypes language extension. Therefore, readPrec (and its
cousin, readListPrec) are marked as GHC-only. Nevertheless, it is
recommended to use readPrec instead of readsPrec whenever possible
for the efficiency improvements it brings.
As mentioned above, derived Read instances in GHC will implement
readPrec instead of readsPrec. The default implementations of
readsPrec (and its cousin, readList) will simply use readPrec under
the hood. If you are writing a Read instance by hand, it is recommended
to write it like so:
instanceReadT wherereadPrec= ...readListPrec=readListPrecDefault
Methods
Arguments
| :: Int | the operator precedence of the enclosing
context (a number from |
| -> ReadS a |
attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by
showsPrec, and delivers the value that
showsPrec started with.
readList :: ReadS [a] Source #
The method readList is provided to allow the programmer to
give a specialised way of parsing lists of values.
For example, this is used by the predefined Read instance of
the Char type, where values of type String should be are
expected to use double quotes, rather than square brackets.
readPrec :: ReadPrec a Source #
Proposed replacement for readsPrec using new-style parsers (GHC only).
readListPrec :: ReadPrec [a] Source #
Proposed replacement for readList using new-style parsers (GHC only).
The default definition uses readList. Instances that define readPrec
should also define readListPrec as readListPrecDefault.
Instances
| Read All | Since: base-2.1 |
| Read Any | Since: base-2.1 |
| Read Version | Since: base-2.1 |
| Read Void | Reading a Since: base-4.8.0.0 |
| Read CBool | |
| Read CChar | |
| Read CClock | |
| Read CDouble | |
| Read CFloat | |
| Read CInt | |
| Read CIntMax | |
| Read CIntPtr | |
| Read CLLong | |
| Read CLong | |
| Read CPtrdiff | |
| Read CSChar | |
| Read CSUSeconds | |
Defined in Foreign.C.Types | |
| Read CShort | |
| Read CSigAtomic | |
Defined in Foreign.C.Types | |
| Read CSize | |
| Read CTime | |
| Read CUChar | |
| Read CUInt | |
| Read CUIntMax | |
| Read CUIntPtr | |
| Read CULLong | |
| Read CULong | |
| Read CUSeconds | |
| Read CUShort | |
| Read CWchar | |
| Read IntPtr | |
| Read WordPtr | |
| Read Associativity | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
| Read DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Read Fixity | Since: base-4.6.0.0 |
| Read SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Read SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Read SeekMode | Since: base-4.2.0.0 |
| Read ExitCode | |
| Read BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types | |
| Read Newline | Since: base-4.3.0.0 |
| Read NewlineMode | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types | |
| Read IOMode | Since: base-4.2.0.0 |
| Read Int16 | Since: base-2.1 |
| Read Int32 | Since: base-2.1 |
| Read Int64 | Since: base-2.1 |
| Read Int8 | Since: base-2.1 |
| Read GeneralCategory | Since: base-2.1 |
| Read Word16 | Since: base-2.1 |
| Read Word32 | Since: base-2.1 |
| Read Word64 | Since: base-2.1 |
| Read CBlkCnt | |
| Read CBlkSize | |
| Read CCc | |
| Read CClockId | |
| Read CDev | |
| Read CFsBlkCnt | |
| Read CFsFilCnt | |
| Read CGid | |
| Read CId | |
| Read CIno | |
| Read CKey | |
| Read CMode | |
| Read CNfds | |
| Read CNlink | |
| Read COff | |
| Read CPid | |
| Read CRLim | |
| Read CSocklen | |
| Read CSpeed | |
| Read CSsize | |
| Read CTcflag | |
| Read CUid | |
| Read Fd | |
| Read Lexeme | Since: base-2.1 |
| Read ByteString | |
Defined in Data.ByteString.Internal | |
| Read ByteString | |
Defined in Data.ByteString.Lazy.Internal | |
| Read ShortByteString | |
Defined in Data.ByteString.Short.Internal | |
| Read IntSet | |
| Read Ordering | Since: base-2.1 |
| Read AddrInfoFlag | |
Defined in Network.Socket.Info | |
| Read NameInfoFlag | |
Defined in Network.Socket.Info | |
| Read SocketOption | |
Defined in Network.Socket.Options | |
| Read Family | |
| Read PortNumber | |
Defined in Network.Socket.Types | |
| Read SocketType | |
Defined in Network.Socket.Types | |
| Read Count Source # | |
| Read Count | |
| Read Clock | |
| Read MicroSecond64 | |
| Read MilliSecond64 | |
| Read NanoSecond64 | |
| Read RelTime | |
| Read RelTime64 | |
| Read Word8 | Since: base-2.1 |
| Read Integer | Since: base-2.1 |
| Read Natural | Since: base-4.8.0.0 |
| Read () | Since: base-2.1 |
| Read Bool | Since: base-2.1 |
| Read Char | Since: base-2.1 |
| Read Double | Since: base-2.1 |
| Read Float | Since: base-2.1 |
| Read Int | Since: base-2.1 |
| Read Word | Since: base-4.5.0.0 |
| Read a => Read (ZipList a) | Since: base-4.7.0.0 |
| Read a => Read (Complex a) | Since: base-2.1 |
| Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Read a => Read (First a) | Since: base-2.1 |
| Read a => Read (Last a) | Since: base-2.1 |
| Read a => Read (Down a) | This instance would be equivalent to the derived instances of the
Since: base-4.7.0.0 |
| Read a => Read (First a) | Since: base-4.9.0.0 |
| Read a => Read (Last a) | Since: base-4.9.0.0 |
| Read a => Read (Max a) | Since: base-4.9.0.0 |
| Read a => Read (Min a) | Since: base-4.9.0.0 |
| Read a => Read (Option a) | Since: base-4.9.0.0 |
| Read m => Read (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods readsPrec :: Int -> ReadS (WrappedMonoid m) Source # readList :: ReadS [WrappedMonoid m] Source # readPrec :: ReadPrec (WrappedMonoid m) Source # readListPrec :: ReadPrec [WrappedMonoid m] Source # | |
| Read a => Read (Dual a) | Since: base-2.1 |
| Read a => Read (Product a) | Since: base-2.1 |
| Read a => Read (Sum a) | Since: base-2.1 |
| Read a => Read (NonEmpty a) | Since: base-4.11.0.0 |
| Read p => Read (Par1 p) | Since: base-4.7.0.0 |
| (Integral a, Read a) => Read (Ratio a) | Since: base-2.1 |
| Read e => Read (IntMap e) | |
| Read a => Read (Seq a) | |
| Read a => Read (ViewL a) | |
| Read a => Read (ViewR a) | |
| (Read a, Ord a) => Read (Set a) | |
| Read a => Read (Tree a) | |
| Read a => Read (Forest a) | |
| (Ord a, Read a) => Read (Heap a) | |
| Read a => Read (Tree a) | |
| Read a => Read (Array a) | |
| (Unbox a, Read a, Show a) => Read (Array a) | |
| (Eq a, Hashable a, Read a) => Read (HashSet a) | |
| Read a => Read (Maybe a) | Since: base-2.1 |
| Read a => Read (a) | Since: base-4.15 |
| Read a => Read [a] | Since: base-2.1 |
| (Read a, Read b) => Read (Either a b) | Since: base-3.0 |
| HasResolution a => Read (Fixed a) | Since: base-4.3.0.0 |
| Read (Proxy t) | Since: base-4.7.0.0 |
| (Read a, Read b) => Read (Arg a b) | Since: base-4.9.0.0 |
| (Ix a, Read a, Read b) => Read (Array a b) | Since: base-2.1 |
| Read (U1 p) | Since: base-4.9.0.0 |
| Read (V1 p) | Since: base-4.9.0.0 |
| (Ord k, Read k, Read e) => Read (Map k e) | |
| (Read p, Read a) => Read (Entry p a) | |
| Read a => Read (SerialT Identity a) Source # | |
| Read a => Read (WSerialT Identity a) Source # | |
| Read a => Read (ZipSerialM Identity a) Source # | |
Defined in Streamly.Internal.Data.Stream.Zip Methods readsPrec :: Int -> ReadS (ZipSerialM Identity a) Source # readList :: ReadS [ZipSerialM Identity a] Source # readPrec :: ReadPrec (ZipSerialM Identity a) Source # readListPrec :: ReadPrec [ZipSerialM Identity a] Source # | |
| Read a => Read (CrossStream Identity a) | |
| Read a => Read (Stream Identity a) | |
| Read a => Read (CrossStreamK Identity a) | |
| Read a => Read (StreamK Identity a) | |
| (Read1 m, Read a) => Read (ListT m a) | |
| (Read1 m, Read a) => Read (MaybeT m a) | |
| (Eq k, Hashable k, Read k, Read e) => Read (HashMap k e) | |
| (Read a, Read b) => Read (a, b) | Since: base-2.1 |
| Read a => Read (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Read (f a) => Read (Ap f a) | Since: base-4.12.0.0 |
| Read (f a) => Read (Alt f a) | Since: base-4.8.0.0 |
| a ~ b => Read (a :~: b) | Since: base-4.7.0.0 |
| Read (f p) => Read (Rec1 f p) | Since: base-4.7.0.0 |
| (Read e, Read1 m, Read a) => Read (ErrorT e m a) | |
| (Read e, Read1 m, Read a) => Read (ExceptT e m a) | |
| (Read1 f, Read a) => Read (IdentityT f a) | |
| (Read w, Read1 m, Read a) => Read (WriterT w m a) | |
| (Read w, Read1 m, Read a) => Read (WriterT w m a) | |
| (Read a, Read b, Read c) => Read (a, b, c) | Since: base-2.1 |
| (Read1 f, Read1 g, Read a) => Read (Product f g a) | Since: base-4.9.0.0 |
| (Read1 f, Read1 g, Read a) => Read (Sum f g a) | Since: base-4.9.0.0 |
| a ~~ b => Read (a :~~: b) | Since: base-4.10.0.0 |
| (Read (f p), Read (g p)) => Read ((f :*: g) p) | Since: base-4.7.0.0 |
| (Read (f p), Read (g p)) => Read ((f :+: g) p) | Since: base-4.7.0.0 |
| Read c => Read (K1 i c p) | Since: base-4.7.0.0 |
| (Read a, Read b, Read c, Read d) => Read (a, b, c, d) | Since: base-2.1 |
| (Read1 f, Read1 g, Read a) => Read (Compose f g a) | Since: base-4.9.0.0 |
| Read (f (g p)) => Read ((f :.: g) p) | Since: base-4.7.0.0 |
| Read (f p) => Read (M1 i c f p) | Since: base-4.7.0.0 |
| (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l) | Since: base-2.1 |
Defined in GHC.Read | |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: base-2.1 |
Defined in GHC.Read | |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: base-2.1 |
Defined in GHC.Read Methods readsPrec :: Int -> ReadS (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # readList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source # readPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source # | |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: base-2.1 |
Defined in GHC.Read Methods readsPrec :: Int -> ReadS (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # readList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source # readPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source # | |
class Monad m => MonadIO (m :: Type -> Type) where Source #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Methods
liftIO :: IO a -> m a Source #
Lift a computation from the IO monad.
This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations
(i.e. IO is the base monad for the stack).
Example
import Control.Monad.Trans.State -- from the "transformers" library printState :: Show s => StateT s IO () printState = do state <- get liftIO $ print state
Had we omitted , we would have ended up with this error:liftIO
• Couldn't match type ‘IO’ with ‘StateT s IO’ Expected type: StateT s IO () Actual type: IO ()
The important part here is the mismatch between StateT s IO () and .IO ()
Luckily, we know of a function that takes an and returns an IO a(m a): ,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
Instances
class Monad m => MonadThrow (m :: Type -> Type) where Source #
A class for monads in which exceptions may be thrown.
Instances should obey the following law:
throwM e >> x = throwM e
In other words, throwing an exception short-circuits the rest of the monadic computation.
Methods
throwM :: Exception e => e -> m a Source #
Throw an exception. Note that this throws when this action is run in
the monad m, not when it is applied. It is a generalization of
Control.Exception's throwIO.
Should satisfy the law:
throwM e >> f = throwM e
Instances
class Monad m => MonadReader r (m :: Type -> Type) | m -> r where Source #
See examples in Control.Monad.Reader.
Note, the partially applied function type (->) r is a simple reader monad.
See the instance declaration below.
Methods
Retrieves the monad environment.
Arguments
| :: (r -> r) | The function to modify the environment. |
| -> m a |
|
| -> m a |
Executes a computation in a modified environment.
Arguments
| :: (r -> a) | The selector function to apply to the environment. |
| -> m a |
Retrieves a function of the current environment.
Instances
class MonadTrans (t :: (Type -> Type) -> Type -> Type) where Source #
The class of monad transformers. Instances should satisfy the
following laws, which state that lift is a monad transformation:
Methods
lift :: Monad m => m a -> t m a Source #
Lift a computation from the argument monad to the constructed monad.
Instances
| MonadTrans AheadT Source # | |
| MonadTrans AsyncT Source # | |
| MonadTrans WAsyncT Source # | |
| MonadTrans ParallelT Source # | |
| MonadTrans SerialT Source # | |
| MonadTrans WSerialT Source # | |
| MonadTrans CrossStream | |
Defined in Streamly.Internal.Data.Stream.Type | |
| MonadTrans CrossStreamK | |
Defined in Streamly.Internal.Data.StreamK.Type | |
| MonadTrans ListT | |
| MonadTrans MaybeT | |
| Monoid w => MonadTrans (AccumT w) | |
| MonadTrans (ErrorT e) | |
| MonadTrans (ExceptT e) | |
| MonadTrans (IdentityT :: (Type -> Type) -> Type -> Type) | |
| MonadTrans (ReaderT r) | |
| MonadTrans (SelectT r) | |
| MonadTrans (StateT s) | |
| MonadTrans (StateT s) | |
| MonadTrans (WriterT w) | |
| Monoid w => MonadTrans (WriterT w) | |
| Monoid w => MonadTrans (WriterT w) | |
| MonadTrans (ContT r) | |
| MonadTrans (RWST r w s) | |
| Monoid w => MonadTrans (RWST r w s) | |
| Monoid w => MonadTrans (RWST r w s) | |
Identity functor and monad. (a non-strict monad)
Since: base-4.8.0.0
Instances
The IsList class and its methods are intended to be used in
conjunction with the OverloadedLists extension.
Since: base-4.7.0.0
Instances
Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).
Minimal complete definition