Skip to content

Commit 15fa318

Browse files
committed
docs: add usage section to README
1 parent 778a8d6 commit 15fa318

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ A logger effect for the
44
[`fused-effects`](https://github.com/fused-effects/fused-effects) library, based
55
on the [`monad-logger`](https://github.com/snoyberg/monad-logger) API.
66

7+
# Usage
8+
In addition to `fused-effects-logger`, you most probably want to add
9+
`monad-logger` as well in order to use its logging functions.
10+
11+
Here is a simple example to start running a program that logs to `stderr`:
12+
13+
```haskell
14+
{-# LANGUAGE OverloadedStrings #-}
15+
{-# LANGUAGE TemplateHaskell #-}
16+
17+
module Main (main) where
18+
19+
import Control.Carrier.Lift (runM)
20+
import Control.Carrier.Logger.IO (runStderrLoggerIO)
21+
import Control.Effect.Lift (sendM)
22+
import Control.Monad.Logger (logInfo)
23+
24+
main :: IO ()
25+
main = runM . runStderrLoggerIO $ do
26+
$(logInfo) "hello from fused-effects-logger"
27+
sendM (print 42)
28+
```
29+
30+
It should produce the output:
31+
32+
```
33+
[Info] hello from fused-effects-logger @(test-logger-0.1.0.0-KTuyx50rxPBAwC1EHp8UuV-test-logger-exe:Main app/Main.hs:13:4)
34+
42
35+
```
36+
737
# Contributing
838

939
Please follow the process describe in [`RELEASE.md`](./RELEASE.md) to release

0 commit comments

Comments
 (0)