Hoogle Search

Within LTS Haskell 24.48 (ghc-9.10.3)

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

  1. formatWith :: forall msg (m :: Type -> Type) . (msg -> Text) -> LogAction m Text -> LogAction m msg

    co-log Colog.Message

    Alias for cmap specialized for formatting purposes. If you have an action that can output Text (for example logTextStdout), you can convert it to the action that can print SimpleMsg or Message:

    logSimpleMsgStdout :: LogAction IO SimpleMsg
    logSimpleMsgStdout = formatWith fmtSimpleMessage logTextStdout
    
    logMessageStdout :: LogAction IO Message
    logMessageStdout = formatWith fmtMessage logTextStdout
    

  2. formattedMessage :: [Text] -> Text -> IO ()

    colourista Colourista.IO

    Print message with specified list of formatting options. See formatWith for more details. If this function takes empty list, no formatting is applied.

  3. formatWith :: (IsString str, Semigroup str) => [str] -> str -> str

    colourista Colourista.Pure

    General purpose function to format strings with multiple options. If this function takes empty list as an argument, no formatting is applied. Some typical usages include but not limited to:

    1. Green text: formatWith [green] myString
    2. Bold red text: formatWith [bold, red] myString
    3. Blue text on white background: formatWith [blue, whiteBg] myString
    4. Italicized yellow on cyan background: formatWith [italic, yellow, cyanBg] myString
    ⚠ Caution: Double underlining doubleUnderline is not widely supported. It is also not natively supported on Windows 10.

  4. forwardOptions :: InfoMod a

    configuration-tools Configuration.Utils.CommandLine

    Intersperse matched options and arguments normally, but allow unmatched options to be treated as positional arguments. This is sometimes useful if one is wrapping a third party cli tool and needs to pass options through, while also providing a handful of their own options. Not recommended in general as typos by the user may not yield a parse error and cause confusion.

  5. forkP :: MonadBaseControl IO m => String -> m () -> m ThreadId

    consumers Database.PostgreSQL.Consumers.Utils

    Modified version of fork that propagates thrown exceptions to the parent thread.

  6. forever :: Dsl k r a => k r a -> r

    control-dsl Control.Dsl

    No documentation available.

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

    control-monad-free Control.Monad.Free

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

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

    control-monad-free Control.Monad.Free

    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.

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

    control-monad-free Control.Monad.Free

    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.

  10. forkThread :: Program τ α -> Program τ (Thread α)

    core-program Core.Program.Threads

    Fork a thread. The child thread will run in the same Context as the calling Program, including sharing the user-defined application state value. If you want to find out what the result of a thread was use waitThread on the Thread object returned from this function. For example:

    t1 <- forkThread $ do
    info "Doing interesting stuff concurrently"
    pure True
    
    ...
    
    result <- waitThread t1
    
    if result
    then -- expected
    else -- not good
    
    If you don't need the result, you can use forkThread_ instead. Threads that are launched off as children are on their own! If the code in the child thread throws an exception that is not caught within that thread, the exception will kill the thread. Threads dying without telling anyone is a bit of an anti-pattern, so this library logs a warning-level log message if this happens. (this function wraps base's forkIO) Concerning telemetry Note that threads inherit the telemetry state from their parent. If you are using the tracing features from core-telemetry any telemetry registered in that side task will be included in the enclosing span active in the parent thread that spawned the thread:
    t2 <- forkThread $ do
    info "Performing quick side task"
    telemetry
    [ 'metric "counter" 42
    ]
    ...
    
    In this case the "counter" field in the parent thread's current span will get the value 42. This is appropriate for the common case where you are doing small side tasks concurrently to accelerate a larger computation. But at other times you are launching off a fully independent control flow and want it to have its own telemetry. In those cases, you'll want to start a new span (or even a new trace) immediately after forking the thread:
    forkThread_ $ do
    encloseSpan "subTask" $ do
    ...
    
    any telemetry from this worker thread will be appropriately nested in a new child span called "subTask".

Page 159 of many | Previous | Next