Hoogle Search

Within LTS Haskell 24.3 (ghc-9.10.2)

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

  1. For :: [x] -> Option2D x y

    easyplot Graphics.EasyPlot

    Plots the function only for the given x values

  2. For :: Expr -> Expr -> Expr -> [Stmt] -> Stmt

    language-c99-simple Language.C99.Simple.AST

    No documentation available.

  3. For :: t -> t -> Expr t -> ForContent t -> t -> Block t -> Statement t

    yi-mode-javascript Yi.Syntax.JavaScript

    No documentation available.

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

    base Control.Monad

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

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

    base 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.

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

    base 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.

  7. forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId

    base Control.Concurrent

    Fork a thread and call the supplied function when the thread is about to terminate, with an exception or a returned value. The function is called with asynchronous exceptions masked.

    forkFinally action and_then =
    mask $ \restore ->
    forkIO $ try (restore action) >>= and_then
    
    This function is useful for informing the parent when a child terminates, for example.

  8. forkIO :: IO () -> IO ThreadId

    base Control.Concurrent

    Creates a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread. The new thread will be a lightweight, unbound thread. Foreign calls made by this thread are not guaranteed to be made by any particular OS thread; if you need foreign calls to be made by a particular OS thread, then use forkOS instead. The new thread inherits the masked state of the parent (see mask). The newly created thread has an exception handler that discards the exceptions BlockedIndefinitelyOnMVar, BlockedIndefinitelyOnSTM, and ThreadKilled, and passes all other exceptions to the uncaught exception handler. WARNING: Exceptions in the new thread will not be rethrown in the thread that created it. This means that you might be completely unaware of the problem if/when this happens. You may want to use the async library instead.

  9. forkIOWithUnmask :: ((forall a . () => IO a -> IO a) -> IO ()) -> IO ThreadId

    base Control.Concurrent

    Like forkIO, but the child thread is passed a function that can be used to unmask asynchronous exceptions. This function is typically used in the following way

    ... mask_ $ forkIOWithUnmask $ \unmask ->
    catch (unmask ...) handler
    
    so that the exception handler in the child thread is established with asynchronous exceptions masked, meanwhile the main body of the child thread is executed in the unmasked state. Note that the unmask function passed to the child thread should only be used in that thread; the behaviour is undefined if it is invoked in a different thread.

  10. forkOS :: IO () -> IO ThreadId

    base Control.Concurrent

    Like forkIO, this sparks off a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread. However, forkOS creates a bound thread, which is necessary if you need to call foreign (non-Haskell) libraries that make use of thread-local state, such as OpenGL (see Control.Concurrent#boundthreads). Using forkOS instead of forkIO makes no difference at all to the scheduling behaviour of the Haskell runtime system. It is a common misconception that you need to use forkOS instead of forkIO to avoid blocking all the Haskell threads when making a foreign call; this isn't the case. To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe.

Page 6 of many | Previous | Next