mirror of
https://github.com/polysemy-research/polysemy.git
synced 2024-09-11 02:25:43 +03:00
parent
43a67061fb
commit
39dcd29c3a
@ -1,5 +1,9 @@
|
||||
# Changelog for polysemy
|
||||
|
||||
## Unreleased
|
||||
|
||||
* Deprecate `traceToIO` and replace it with `traceToStdout` and `traceToStderr`
|
||||
|
||||
## 1.5.0.0 (2021-03-30)
|
||||
|
||||
### Breaking Changes
|
||||
|
@ -8,6 +8,9 @@ module Polysemy.Trace
|
||||
, trace
|
||||
|
||||
-- * Interpretations
|
||||
, traceToHandle
|
||||
, traceToStdout
|
||||
, traceToStderr
|
||||
, traceToIO
|
||||
, runTraceList
|
||||
, ignoreTrace
|
||||
@ -19,6 +22,7 @@ module Polysemy.Trace
|
||||
|
||||
import Polysemy
|
||||
import Polysemy.Output
|
||||
import System.IO (stdout, stderr, hPutStrLn, Handle)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@ -29,14 +33,42 @@ data Trace m a where
|
||||
makeSem ''Trace
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Run a 'Trace' effect by printing the messages to the provided 'Handle'.
|
||||
--
|
||||
-- @since TODO
|
||||
traceToHandle :: Member (Embed IO) r => Handle -> Sem (Trace ': r) a -> Sem r a
|
||||
traceToHandle handle = interpret $ \case
|
||||
Trace m -> embed $ hPutStrLn handle m
|
||||
{-# INLINE traceToHandle #-}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Run a 'Trace' effect by printing the messages to stdout.
|
||||
--
|
||||
-- @since TODO
|
||||
traceToStdout :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
|
||||
traceToStdout = traceToHandle stdout
|
||||
{-# INLINE traceToStdout #-}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Run a 'Trace' effect by printing the messages to stderr.
|
||||
--
|
||||
-- @since TODO
|
||||
traceToStderr :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
|
||||
traceToStderr = traceToHandle stderr
|
||||
{-# INLINE traceToStderr #-}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- | Run a 'Trace' effect by printing the messages to stdout.
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
traceToIO :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
|
||||
traceToIO = interpret $ \case
|
||||
Trace m -> embed $ putStrLn m
|
||||
traceToIO = traceToStdout
|
||||
{-# INLINE traceToIO #-}
|
||||
{-# deprecated traceToIO "Use traceToStdout" #-}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user