Hoogle Search
Within LTS Haskell 24.35 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
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.
forkP :: MonadBaseControl IO m => String -> m () -> m ThreadIdconsumers Database.PostgreSQL.Consumers.Utils Modified version of fork that propagates thrown exceptions to the parent thread.
forever :: Dsl k r a => k r a -> rcontrol-dsl Control.Dsl No documentation available.
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_.
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.
forever :: Applicative f => f a -> f bcontrol-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.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".forkThread_ :: Program τ α -> Program τ ()core-program Core.Program.Threads Fork a thread with forkThread but do not wait for a result. This is on the assumption that the sub program will either be a side-effect and over quickly, or long-running daemon thread (presumably containing a forever loop in it), never returning.
forgetDisproof :: Decision a -> Maybe adecidable Data.Type.Predicate Converts a Decision to a Maybe. Drop the witness of disproof of a, returning Just if Proved (with the proof) and Nothing if Disproved.
forgetProof :: Decision a -> Maybe (Refuted a)decidable Data.Type.Predicate Drop the witness of proof of a, returning Nothing if Proved and Just if Disproved (with the disproof).