Hoogle Search

Within LTS Haskell 24.34 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. forkOn :: Int -> IO () -> IO ThreadId

    ghc-internal GHC.Internal.Conc.Sync

    Like forkIO, but lets you specify on which capability the thread should run. Unlike a forkIO thread, a thread created by forkOn will stay on the same capability for its entire lifetime (forkIO threads can migrate between capabilities according to the scheduling policy). forkOn is useful for overriding the scheduling policy when you know in advance how best to distribute the threads. The Int argument specifies a capability number (see getNumCapabilities). Typically capabilities correspond to physical processors, but the exact behaviour is implementation-dependent. The value passed to forkOn is interpreted modulo the total number of capabilities as returned by getNumCapabilities. GHC note: the number of capabilities is specified by the +RTS -N option when the program is started. Capabilities can be fixed to actual processor cores with +RTS -qa if the underlying operating system supports that, although in practice this is usually unnecessary (and may actually degrade performance in some cases - experimentation is recommended).

  2. forkOnWithUnmask :: Int -> ((forall a . () => IO a -> IO a) -> IO ()) -> IO ThreadId

    ghc-internal GHC.Internal.Conc.Sync

    Like forkIOWithUnmask, but the child thread is pinned to the given CPU, as with forkOn.

  3. forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)

    ghc-internal GHC.Internal.Control.Monad

    forM is mapM with its arguments flipped. For a version that ignores the results see forM_.

  4. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

    ghc-internal GHC.Internal.Control.Monad

    forM_ is mapM_ with its arguments flipped. For a version that doesn't ignore the results see forM. forM_ is just like for_, but specialised to monadic actions.

  5. forever :: Applicative f => f a -> f b

    ghc-internal GHC.Internal.Control.Monad

    Repeat an action indefinitely.

    Examples

    A common use of forever is to process input from network sockets, Handles, and channels (e.g. MVar and Chan). For example, here is how we might implement an echo server, using forever both to listen for client connections on a network socket and to echo client input on client connection handles:
    echoServer :: Socket -> IO ()
    echoServer socket = forever $ do
    client <- accept socket
    forkFinally (echo client) (\_ -> hClose client)
    where
    echo :: Handle -> IO ()
    echo client = forever $
    hGetLine client >>= hPutStrLn client
    
    Note that "forever" isn't necessarily non-terminating. If the action is in a MonadPlus and short-circuits after some number of iterations. then forever actually returns mzero, effectively short-circuiting its caller.

  6. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

    ghc-internal GHC.Internal.Data.Foldable

    forM_ is mapM_ with its arguments flipped. For a version that doesn't ignore the results see forM. forM_ is just like for_, but specialised to monadic actions.

  7. for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()

    ghc-internal GHC.Internal.Data.Foldable

    for_ is traverse_ with its arguments flipped. For a version that doesn't ignore the results see for. This is forM_ generalised to Applicative actions. for_ is just like forM_, but generalised to Applicative actions.

    Examples

    Basic usage:
    >>> for_ [1..4] print
    1
    2
    3
    4
    

  8. forAccumM :: (Monad m, Traversable t) => s -> t a -> (s -> a -> m (s, b)) -> m (s, t b)

    ghc-internal GHC.Internal.Data.Traversable

    forAccumM is mapAccumM with the arguments rearranged.

  9. forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)

    ghc-internal GHC.Internal.Data.Traversable

    forM is mapM with its arguments flipped. For a version that ignores the results see forM_.

  10. formatRealFloat :: RealFloat a => FFFormat -> Maybe Int -> a -> String

    ghc-internal GHC.Internal.Float

    No documentation available.

Page 60 of many | Previous | Next