HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestreamly-0.10.1Haskell2010

Streamly.Data.Stream.MkType

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:

Example4 expressions
: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.

Example2 expressions
import Streamly.Data.Stream.MkTypeimport qualified Streamly.Data.Stream.Prelude as Stream

For Streamly.Prelude.AsyncT monad type with a concurrent cross product bind:

Example1 expression
:{ bind = flip (Stream.parConcatMap id) $(mkCrossType "AsyncT" "bind" True):}

For Streamly.Prelude.WAsyncT monad type with a concurrent interleaved bind:

Example1 expression
:{ bind = flip (Stream.parConcatMap (Stream.interleaved True)) $(mkCrossType "WAsyncT" "bind" True):}

For Streamly.Prelude.AheadT monad type with a concurrent ordered cross product bind:

Example1 expression
:{ bind = flip (Stream.parConcatMap (Stream.ordered True)) $(mkCrossType "AheadT" "bind" True):}

For Streamly.Prelude.ParallelT monad type with an eager concurrent cross product bind:

Example1 expression
:{ parBind = flip (Stream.parConcatMap (Stream.eager True)) $(mkCrossType "ParallelT" "parBind" True):}

For Streamly.Prelude.ZipSerialM serial zipping applicative type:

Example1 expression
:{ zipApply = Stream.zipWith ($) $(mkZipType "ZipSerialM" "zipApply" False):}

For Streamly.Prelude.ZipAsync concurrent zipping applicative type:

Example1 expression
:{ 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:

Example2 expressions
bind = flip (Stream.parConcatMap id)expr <- runQ (mkCrossType "AsyncT" "bind" True)
> putStrLn $ pprint expr
  • 1 type
  • 7 classes
  • 3 values
  • Packagestreamly-0.10.1
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceMkType.hs

Imports for Examples

0 declarations
Example4 expressions
:mimport Language.Haskell.THimport qualified Streamly.Data.Stream.Prelude as Streamimport Streamly.Data.Stream.MkType

Template Haskell Macros

2 declarations
valuemkZipType
  1. :: String

    Name of the type

  2. -> String

    Function to use for (<*>)

  3. -> Bool

    True if (<*>) requires MonadAsync constraint (concurrent)

  4. -> Q [Dec]
#

Create a type with a zip-like applicative.

Example2 expressions
expr <- runQ (mkZipType "ZipStream" "zipApply" False)putStrLn $ pprint exprnewtype ZipStream m a    = ZipStream (Stream.Stream m a)    deriving FoldablemkZipStream :: Stream.Stream m a -> ZipStream m amkZipStream = ZipStreamunZipStream :: ZipStream m a -> Stream.Stream m aunZipStream (ZipStream strm) = strmderiving 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)}
valuemkCrossType
  1. :: String

    Name of the type

  2. -> String

    Function to use for (>>=)

  3. -> Bool

    True if (>>=) requires MonadAsync constraint (concurrent)

  4. -> Q [Dec]
#

Create a type with specific stream combination properties.

Example2 expressions
expr <- runQ (mkCrossType "Parallel" "parBind" True)putStrLn $ pprint exprnewtype Parallel m a = Parallel (Stream.Stream m a)mkParallel :: Stream.Stream m a -> Parallel m amkParallel = ParallelunParallel :: Parallel m a -> Stream.Stream m aunParallel (Parallel strm) = strminstance 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

9 declarations
classclass Read a where
#

Parsing of Strings, producing values.

Derived instances of Read make the following assumptions, which derived instances of Text.Show.Show obey:

  • If the constructor is defined to be an infix operator, then the derived Read instance 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 Read will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration.

  • The derived Read instance 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 = 5

Note 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 = readListPrecDefault

Why 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:

instance Read T where
  readPrec     = ...
  readListPrec = readListPrecDefault

Methods

  • readsPrec :: Int -> 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 Text.Show.Show satisfy the following:

    That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

  • readList :: ReadS [a]

    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 are expected to use double quotes, rather than square brackets.

  • readPrec :: ReadPrec a

    Proposed replacement for readsPrec using new-style parsers (GHC only).

  • readListPrec :: ReadPrec [a]

    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.

Instances239Read, …
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Read ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Read IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Read FileTypeDefined in directory-1.3.8.5 · System.Directory.Internal.Common
  • Read PermissionsDefined in directory-1.3.8.5 · System.Directory.Internal.Common
  • Read XdgDirectoryDefined in directory-1.3.8.5 · System.Directory.Internal.Common
  • Read XdgDirectoryListDefined in directory-1.3.8.5 · System.Directory.Internal.Common
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Read

    Reading a Void value is always a parse error, considering Void as a data type with no constructors.

  • Read ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Read AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Read CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Read ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Read BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Read Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Read GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read AddrInfoFlagDefined in network-3.2.8.0 · Network.Socket.Info
  • Read NameInfoFlagDefined in network-3.2.8.0 · Network.Socket.Info
  • Read SocketOptionDefined in network-3.2.8.0 · Network.Socket.Options
  • Read CmsgIdDefined in network-3.2.8.0 · Network.Socket.Posix.Cmsg
  • Read FamilyDefined in network-3.2.8.0 · Network.Socket.Types
  • Read PortNumberDefined in network-3.2.8.0 · Network.Socket.Types
  • Read SocketTypeDefined in network-3.2.8.0 · Network.Socket.Types
  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 9297814886316923340 13679457532755275413)
  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix32
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 142593372 1604540297)
  • Read CountDefined in streamly-0.10.1 · Streamly.Internal.Data.Channel.Types
  • Read CountDefined in streamly-core-0.2.2 · Streamly.Internal.Data.SVar.Type
  • Read ClockDefined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Clock.Type
  • Read TimeSpecDefined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.TimeSpec
  • Read MicroSecond64Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Units
  • Read MilliSecond64Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Units
  • Read NanoSecond64Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Units
  • Read RelTimeDefined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Units
  • Read RelTime64Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Time.Units
  • Read I8Defined in text-2.1.3 · Data.Text.Foreign
  • Read TextDefined in text-2.1.3 · Data.Text · orphan
  • Read TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Read FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Read DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read MonthDefined in time-1.12.2 · Data.Time.Calendar.Month

    Read as yyyy-mm.

  • Read QuarterDefined in time-1.12.2 · Data.Time.Calendar.Quarter

    Read as yyyy-Qn.

  • Read QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.Quarter
  • Read DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.Week
  • Read DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Read NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Read UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read UniversalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read LocalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse · orphan
  • Read TimeZoneDefined in time-1.12.2 · Data.Time.Format.Parse · orphan

    This only works for ±HHMM format, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.

  • Read ZonedTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphan

    This only works for a zonedTimeZone in ±HHMM format, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.

  • Read RTLDFlagsDefined in unix-2.8.7.0 · System.Posix.DynamicLinker.Prim
  • Read CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.Common
  • Read OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Read OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.Common
  • Read GroupEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Read UserEntryDefined in unix-2.8.7.0 · System.Posix.User.Common
  • Read ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Read a => Read (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (Tree a)Defined in containers-0.7 · Data.Tree
  • Read a => Read (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

    This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

  • Read a => Read (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

  • Read a => Read (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Read a => Read (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Forest a)Defined in heaps-0.4.1 · Data.Heap
  • Read a => Read (Tree a)Defined in heaps-0.4.1 · Data.Heap
  • Read a => Read (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Read a => Read (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Read a => Read (Array a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Array.Generic
  • Read a => Read (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read e => Read (IntMap e)Defined in containers-0.7 · Data.IntMap.Internal
  • Read m => Read (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Read p => Read (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read vertex => Read (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Read a, Ord a) => Read (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Integral a, Read a) => Read (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ord a, Read a) => Read (Heap a)Defined in heaps-0.4.1 · Data.Heap
  • (Hashable a, Read a) => Read (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • (Unbox a, Read a, Show a) => Read (Array a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Array.Type
  • HasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read a => Read (SerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • Read a => Read (WSerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • Read a => Read (ZipSerialM Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Zip
  • Read a => Read (CrossStream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • Read a => Read (Stream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • Read a => Read (CrossStreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • Read a => Read (StreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • (Read1 f, Read a) => Read (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Read1 m, Read a) => Read (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ix ix, Read ix, Read e, IArray UArray e) => Read (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Read a, Read b) => Read (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Read a, Read b) => Read (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Read a, Read b) => Read (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read p, Read a) => Read (Entry p a)Defined in heaps-0.4.1 · Data.Heap
  • (Ord k, Read k, Read e) => Read (Map k e)Defined in containers-0.7 · Data.Map.Internal
  • (Hashable k, Read k, Read e) => Read (HashMap k e)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
  • (GRead (Rep1 f a), Generic1 f) => Read (FunctorClassesDefault f a)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Read (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read (f a) => Read (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read (f p) => Read (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

    This instance would be equivalent to the derived instances of the Const newtype if the getConst field were removed

  • Read a => Read (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Coercible a b => Read (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • (Read1 f, Read a) => Read (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Read1 f, Read a) => Read (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Read1 f, Read a) => Read (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Read a, Read b, Read c) => Read (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read e, Read1 m, Read a) => Read (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read c => Read (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f a), Read (g a)) => Read (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Read (f a), Read (g a)) => Read (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Read (f p), Read (g p)) => Read ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f p), Read (g p)) => Read ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d) => Read (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read (f (g a)) => Read (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Read (f (g p)) => Read ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (f p) => Read (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (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)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (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)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (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)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (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)Defined in ghc-internal-9.1003.0 · GHC.Internal.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 (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.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)Defined in ghc-internal-9.1003.0 · GHC.Internal.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)Defined in ghc-internal-9.1003.0 · GHC.Internal.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 o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
classclass Monad m => MonadIO (m :: Type -> Type) where
#

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

    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 liftIO, we would have ended up with this error:

    • 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 IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"
    
    > evalStateT printState 3
    3
    
Instances28MonadIO, …
classclass Monad m => MonadThrow (m :: Type -> Type) where
#

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 :: (HasCallStack, Exception e) => e -> m a

    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
Instances27MonadThrow, …
classclass Monad m => MonadReader r (m :: Type -> Type) | m -> r where
#

See examples in Control.Monad.Reader. Note, the partially applied function type (->) r is a simple reader monad. See the instance declaration below.

Methods

  • ask :: m r

    Retrieves the monad environment.

  • local :: (r -> r) -> m a -> m a

    Executes a computation in a modified environment.

  • reader :: (r -> a) -> m a

    Retrieves a function of the current environment.

Instances23MonadReader, …
classclass (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) where
#

The class of monad transformers. For any monad m, the result t m should also be a monad, and lift should be a monad transformation from m to t m, i.e. it should satisfy the following laws:

Since 0.6.0.0 and for GHC 8.6 and later, the requirement that t m be a Monad is enforced by the implication constraint forall m. Monad m => Monad (t m) enabled by the QuantifiedConstraints extension.

Ambiguity error with GHC 9.0 to 9.2.2

These versions of GHC have a bug (https://gitlab.haskell.org/ghc/ghc/-/issues/20582) which causes constraints like

(MonadTrans t, forall m. Monad m => Monad (t m)) => ...

to be reported as ambiguous. For transformers 0.6 and later, this can be fixed by removing the second constraint, which is implied by the first.

Methods

  • lift :: Monad m => m a -> t m a

    Lift a computation from the argument monad to the constructed monad.

Instances20MonadTrans, …
newtypenewtype Identity a
#

Identity functor and monad. (a non-strict monad)

Examples
Example1 expression
fmap (+1) (Identity 0)Identity 1
Example1 expression
Identity [1, 2, 3] <> Identity [4, 5, 6]Identity [1,2,3,4,5,6]
>>> do
      x <- Identity 10
      y <- Identity (x + 5)
      pure (x + y)
Identity 25
Instances108Monad, Functor, MonadFix, Applicative, Foldable, MonadZip, …
classclass IsList l where
#

The IsList class and its methods are intended to be used in conjunction with the OverloadedLists extension.

Instances30IsList, …
  • IsList ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • IsList BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal

    For long or infinite lists use fromList because it uses LazyByteString otherwise use fromListN which uses StrictByteString.

  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • IsList ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • IsList IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • IsList VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList CallStackDefined in ghc-internal-9.1003.0 · GHC.Internal.IsList

    Be aware that 'fromList . toList = id' only for unfrozen CallStacks, since toList removes frozenness information.

  • IsList TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedLists['\55555'] :: Text"\65533"
  • IsList TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedLists['\55555'] :: Data.Text.Lazy.Text"\65533"
  • IsList (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • IsList (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • IsList (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • IsList (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • IsList (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • IsList [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.IsList
  • Ord a => IsList (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Hashable a => IsList (HashSet a)Defined in unordered-containers-0.2.21 · Data.HashSet.Internal
  • Prim a => IsList (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • Unbox a => IsList (Array a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Array.Type
  • IsList (SerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • IsList (WSerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • IsList (ZipSerialM Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Zip
  • IsList (CrossStream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • IsList (Stream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • IsList (CrossStreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • IsList (StreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • Ord k => IsList (Map k v)Defined in containers-0.7 · Data.Map.Internal
  • Hashable k => IsList (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal
classclass IsString a where
#

IsString is used in combination with the -XOverloadedStrings language extension to convert the literals to different string types.

For example, if you use the text package, you can say

{-# LANGUAGE OverloadedStrings  #-}

myText = "hello world" :: Text

Internally, the extension will convert this to the equivalent of

myText = fromString @Text ("hello world" :: String)

Note: You can use fromString in normal code as well, but the usual performance/memory efficiency problems with String apply.

Instances22IsString, …
  • IsString BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • IsString TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Text"\65533"
  • IsString BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Builder"\65533"
  • IsString TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Data.Text.Lazy.Text"\65533"
  • IsString (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • IsString a => IsString (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
  • (IsString a, Hashable a) => IsString (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • a ~ Char => IsString (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • a ~ Char => IsString (Array a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Array.Type
  • a ~ Char => IsString [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String

    (a ~ Char) context was introduced in 4.9.0.0

  • a ~ Char => IsString (SerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • a ~ Char => IsString (WSerialT Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Serial
  • a ~ Char => IsString (ZipSerialM Identity a)Defined in streamly-0.10.1 · Streamly.Internal.Data.Stream.Zip
  • a ~ Char => IsString (CrossStream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • a ~ Char => IsString (Stream Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Stream.Type
  • a ~ Char => IsString (CrossStreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • a ~ Char => IsString (StreamK Identity a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.StreamK.Type
  • IsString a => IsString (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
valueap :: Monad m => m (a -> b) -> m a -> m b
#

In many situations, the liftM operations can be replaced by uses of ap, which promotes function application.

return f `ap` x1 `ap` ... `ap` xn

is equivalent to

liftM<n> f x1 x2 ... xn
Examples
Example1 expression
pure (\x y z -> x + y * z) `ap` Just 1 `ap` Just 5 `ap` Just 10Just 51