diff options
author | Matthias Fischmann <mf@zerobuzz.net> | 2015-10-02 15:48:08 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-10-02 15:51:09 +0200 |
commit | 57e3742c20fcc55f21634b6a43fbee47bc053775 (patch) | |
tree | 578092834ba43d465b4bdf3eafacfd9fbd670cc8 | |
parent | eb975d2eec349429e735c272d46a7becccf393c6 (diff) | |
download | haskell-57e3742c20fcc55f21634b6a43fbee47bc053775.tar.gz |
Document peculiarities of `traceM`.
Reviewers: bgamari, hvr, austin
Reviewed By: bgamari, hvr, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1289
-rw-r--r-- | libraries/base/Debug/Trace.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libraries/base/Debug/Trace.hs b/libraries/base/Debug/Trace.hs index 26a19d8f71..653dcab055 100644 --- a/libraries/base/Debug/Trace.hs +++ b/libraries/base/Debug/Trace.hs @@ -150,8 +150,14 @@ traceShowId a = trace (show a) a {-| Like 'trace' but returning unit in an arbitrary 'Applicative' context. Allows -for convenient use in do-notation. Note that the application of 'trace' is not -an action in the 'Applicative' context, as 'traceIO' is in the 'IO' type. +for convenient use in do-notation. + +Note that the application of 'traceM' is not an action in the 'Applicative' +context, as 'traceIO' is in the 'IO' type. While the fresh bindings in the +following example will force the 'traceM' expressions to be reduced every time +the @do@-block is executed, @traceM "not crashed"@ would only be reduced once, +and the message would only be printed once. If your monad is in 'MonadIO', +@liftIO . traceIO@ may be a better option. > ... = do > x <- ... |