HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleco-log-core-0.3.2.2Haskell2010

Colog.Core.IO

SPDX-License-Identifier : MPL-2.0 Maintainer : Co-Log xrom.xkov@gmail.com Stability : Stable Portability : Portable

Introduces logging actions working in MonadIO. These actions are very basic and inefficient because they use the String data type. If you don't want to have extra dependencies and performance of logging is not the bottleneck of your application, then these functions should be enough. Otherwise use functions from the Colog.Actions module from the co-log package.

  • 10 values

String actions

4 declarations

Action that prints String to stdout. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logStringStdout <& "foo"foo

Action that prints String to stderr. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logStringStderr <& "foo"foo

Action that prints String to Handle. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logStringHandle stderr <& "foo"foo
valuewithLogStringFile
  1. :: MonadIO m
  2. => FilePath
  3. -> LogAction m String -> IO r
  4. -> IO r
#

Action that prints String to file. Instead of returning LogAction it's implemented in continuation-passing style because it's more efficient to open file only once at the start of the application and write to Handle instead of opening file each time we need to write to it.

Opens file in AppendMode. Automatically flushes the output buffer.

Example2 expressions
logger action = action <& "foo"withLogStringFile "/dev/stdout" loggerfoo

Show actions

4 declarations
valuelogPrint :: (Show a, MonadIO m) => LogAction m a
#

Action that prints to stdout using Show. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logPrint <& 55
valuelogPrintStderr :: (Show a, MonadIO m) => LogAction m a
#

Action that prints to stderr using Show. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logPrintStderr <& 55
valuelogPrintHandle :: (Show a, MonadIO m) => Handle -> LogAction m a
#

Action that prints to a Handle using Show. This action does not flush the output buffer. If buffering mode is block buffering, the effect of this action can be delayed.

Example1 expression
logPrintHandle stderr <& 55

Various combinators

2 declarations
valueliftLogIO :: MonadIO m => LogAction IO msg -> LogAction m msg
#

Lifts a LogAction over IO into a more general Monad.

Example2 expressions
logToStdout = LogAction putStrLnliftLogIO logToStdout <& "foo"foo
valuelogFlush :: MonadIO m => Handle -> LogAction m a
#

This action can be used in combination with other actions to flush a handle every time you log anything.