| Copyright | (c) Alexey Radkov 2023 |
|---|---|
| License | BSD-style |
| Maintainer | alexey.radkov@gmail.com |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
NgxExport.Tools.Combinators
Description
Synopsis
- voidHandler :: IO a -> IO ByteString
- module NgxExport.Tools.SplitService
Combinators of effectful actions
A set of convenient combinators of effectful actions for building handlers and services tuned for special purposes.
Void handler
Arguments
| :: IO a | Target computation |
| -> IO ByteString |
Runs an effectful computation and then returns an empty ByteString
This combinator saves printing the final return L.empty action in handlers
that return unused or empty ByteString.
For example, handler signalUpconf being declared as an update callback in
type Upconf = [Text]
signalUpconf :: Upconf -> Bool -> IO L.ByteString
signalUpconf upconf = const $ do
mapConcurrently_ getUrl upconf
return L.empty
ngxExportSimpleServiceTyped 'signalUpconf ''Upconf $
PersistentService Nothing
returns an empty bytestring which is not used in a meaningful way, therefore it can be rewritten as
signalUpconf :: Upconf -> Bool -> IO L.ByteString signalUpconf = const . voidHandler . mapConcurrently_ getUrl
which helps to focus better on the computation itself.
Since: 1.2.0
Split services
module NgxExport.Tools.SplitService