Hoogle Search

Within LTS Haskell 22.20 (ghc-9.6.4)

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

  1. bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

    base-prelude BasePrelude

    When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release). A common example is opening a file:

    bracket
    (openFile "filename" ReadMode)
    (hClose)
    (\fileHandle -> do { ... })
    
    The arguments to bracket are in this order so that we can partially apply it, e.g.:
    withFile name mode = bracket (openFile name mode) hClose
    
    Bracket wraps the release action with mask, which is sufficient to ensure that the release action executes to completion when it does not invoke any interruptible actions, even in the presence of asynchronous exceptions. For example, hClose is uninterruptible when it is not racing other uses of the handle. Similarly, closing a socket (from "network" package) is also uninterruptible under similar conditions. An example of an interruptible action is killThread. Completion of interruptible release actions can be ensured by wrapping them in in uninterruptibleMask_, but this risks making the program non-responsive to Control-C, or timeouts. Another option is to run the release action asynchronously in its own thread:
    void $ uninterruptibleMask_ $ forkIO $ do { ... }
    
    The resource will be released as soon as possible, but the thread that invoked bracket will not block in an uninterruptible state.

  2. bracket :: MonadAsyncException m => m a -> (a -> m b) -> (a -> m c) -> m c

    exception-transformers Control.Monad.Exception

    When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release).

  3. bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

    rebase Rebase.Prelude

    When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release). A common example is opening a file:

    bracket
    (openFile "filename" ReadMode)
    (hClose)
    (\fileHandle -> do { ... })
    
    The arguments to bracket are in this order so that we can partially apply it, e.g.:
    withFile name mode = bracket (openFile name mode) hClose
    
    Bracket wraps the release action with mask, which is sufficient to ensure that the release action executes to completion when it does not invoke any interruptible actions, even in the presence of asynchronous exceptions. For example, hClose is uninterruptible when it is not racing other uses of the handle. Similarly, closing a socket (from "network" package) is also uninterruptible under similar conditions. An example of an interruptible action is killThread. Completion of interruptible release actions can be ensured by wrapping them in in uninterruptibleMask_, but this risks making the program non-responsive to Control-C, or timeouts. Another option is to run the release action asynchronously in its own thread:
    void $ uninterruptibleMask_ $ forkIO $ do { ... }
    
    The resource will be released as soon as possible, but the thread that invoked bracket will not block in an uninterruptible state.

  4. bracket :: (HasCallStack, MonadMask m) => m a -> (a -> m c) -> (a -> m b) -> m b

    jsaddle Language.Javascript.JSaddle

    Generalized abstracted pattern of safe resource acquisition and release in the face of errors. The first action "acquires" some value, which is "released" by the second action at the end. The third action "uses" the value and its result is the result of the bracket. If an error is thrown during the use, the release still happens before the error is rethrown. Note that this is essentially a type-specialized version of generalBracket. This function has a more common signature (matching the signature from Control.Exception), and is often more convenient to use. By contrast, generalBracket is more expressive, allowing us to implement other functions like bracketOnError.

  5. bracket :: (HasCallStack, MonadMask m) => m a -> (a -> m c) -> (a -> m b) -> m b

    jsaddle Language.Javascript.JSaddle.Monad

    Generalized abstracted pattern of safe resource acquisition and release in the face of errors. The first action "acquires" some value, which is "released" by the second action at the end. The third action "uses" the value and its result is the result of the bracket. If an error is thrown during the use, the release still happens before the error is rethrown. Note that this is essentially a type-specialized version of generalBracket. This function has a more common signature (matching the signature from Control.Exception), and is often more convenient to use. By contrast, generalBracket is more expressive, allowing us to implement other functions like bracketOnError.

  6. bracket :: MonadUnliftIO m => m a -> (a -> m b) -> (a -> m c) -> m c

    classy-prelude-yesod ClassyPrelude.Yesod

    Allocate and clean up a resource safely. For more information on motivation and usage of this function, see base's bracket. This function has two differences from the one in base. The first, and more obvious, is that it works on any MonadUnliftIO instance, not just IO. The more subtle difference is that this function will use uninterruptible masking for its cleanup handler. This is a subtle distinction, but at a high level, means that resource cleanup has more guarantees to complete. This comes at the cost that an incorrectly written cleanup function cannot be interrupted. For more information, please see https://github.com/fpco/safe-exceptions/issues/3.

  7. bracket :: Program τ ρ -> (ρ -> Program τ γ) -> (ρ -> Program τ α) -> Program τ α

    core-program Core.Program.Exceptions

    Acquire a resource, use it, then release it back. The bracket pattern is common in Haskell for getting a resource ρ needed for a computation, preforming that computation, then returning the resource back to the system. Common examples are when making database connections and doing file or network operations, where you need to make sure you "close" the connection afterward before continuing the program so that scare resources like file handles are released. Typically you have an open and close action that return and take a resource respectively, so you can use those directly, and use a lambda in the third action to actally get at the resource and do something with it when you need it:

    bracket
    (openConnection)
    (closeConnection)
    (c -> do
    this
    thatAndNow
    theOtherThingThatNeeds c
    )
    
    Note that bracket does not catch the exception if one is thrown! The finalizer will run, but then the exception will continue to propogate its way out of your program's call stack. Note also that the result of the cleanup action γ is ignored (it can be () or anythign else; it will be discarded).

  8. bracket :: (HasCallStack, MonadMask m) => m a -> (a -> m b) -> (a -> m c) -> m c

    faktory Faktory.Prelude

    Async safe version of bracket

  9. bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

    hakyllbars Hakyllbars.Common

    When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release). A common example is opening a file:

    bracket
    (openFile "filename" ReadMode)
    (hClose)
    (\fileHandle -> do { ... })
    
    The arguments to bracket are in this order so that we can partially apply it, e.g.:
    withFile name mode = bracket (openFile name mode) hClose
    
    Bracket wraps the release action with mask, which is sufficient to ensure that the release action executes to completion when it does not invoke any interruptible actions, even in the presence of asynchronous exceptions. For example, hClose is uninterruptible when it is not racing other uses of the handle. Similarly, closing a socket (from "network" package) is also uninterruptible under similar conditions. An example of an interruptible action is killThread. Completion of interruptible release actions can be ensured by wrapping them in in uninterruptibleMask_, but this risks making the program non-responsive to Control-C, or timeouts. Another option is to run the release action asynchronously in its own thread:
    void $ uninterruptibleMask_ $ forkIO $ do { ... }
    
    The resource will be released as soon as possible, but the thread that invoked bracket will not block in an uninterruptible state.

  10. bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b

    hie-bios HIE.Bios.Ghc.Gap

    No documentation available.

Page 3 of many | Previous | Next