Skip to content

Commit 0186c1e

Browse files
committed
More Console functions
Add missing functions from Prelude. Match upstream style and comments. Reexport `CONSOLE` effect.
1 parent f9b8901 commit 0186c1e

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

src/Control/Monad/Aff/Console.purs

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
1-
module Control.Monad.Aff.Console where
1+
module Control.Monad.Aff.Console
2+
( module Exports
3+
, log
4+
, logShow
5+
, warn
6+
, warnShow
7+
, error
8+
, errorShow
9+
, info
10+
, infoShow
11+
) where
212

313
import Prelude
14+
import Control.Monad.Eff.Console (CONSOLE) as Exports
415
import Control.Monad.Eff.Console as C
516

6-
import Control.Monad.Aff (Aff())
17+
import Control.Monad.Aff (Aff)
718
import Control.Monad.Eff.Class (liftEff)
819

9-
-- | Logs any string to the console. This basically saves you
10-
-- | from writing `liftEff $ log x` everywhere.
11-
log :: forall e. String -> Aff (console :: C.CONSOLE | e) Unit
20+
-- | Write a message to the console. Shorthand for `liftEff $ log x`.
21+
log :: forall eff. String -> Aff (console :: C.CONSOLE | eff) Unit
1222
log = liftEff <<< C.log
1323

14-
-- | Logs any `Show`-able value to the console. This basically saves you
15-
-- | from writing `liftEff $ logShow x` everywhere.
16-
logShow :: forall e a. (Show a) => a -> Aff (console :: C.CONSOLE | e) Unit
24+
-- | Write a value to the console, using its `Show` instance to produce a
25+
-- | `String`. Shorthand for `liftEff $ logShow x`.
26+
logShow :: forall a eff. Show a => a -> Aff (console :: C.CONSOLE | eff) Unit
1727
logShow = liftEff <<< C.logShow
28+
29+
-- | Write a warning to the console. Shorthand for `liftEff $ warn x`.
30+
warn :: forall eff. String -> Aff (console :: C.CONSOLE | eff) Unit
31+
warn = liftEff <<< C.warn
32+
33+
-- | Write a warning value to the console, using its `Show` instance to produce
34+
-- | a `String`. Shorthand for `liftEff $ warnShow x`.
35+
warnShow :: forall a eff. Show a => a -> Aff (console :: C.CONSOLE | eff) Unit
36+
warnShow = liftEff <<< C.warnShow
37+
38+
-- | Write an error to the console. Shorthand for `liftEff $ error x`.
39+
error :: forall eff. String -> Aff (console :: C.CONSOLE | eff) Unit
40+
error = liftEff <<< C.error
41+
42+
-- | Write an error value to the console, using its `Show` instance to produce a
43+
-- | `String`. Shorthand for `liftEff $ errorShow x`.
44+
errorShow :: forall a eff. Show a => a -> Aff (console :: C.CONSOLE | eff) Unit
45+
errorShow = liftEff <<< C.errorShow
46+
47+
-- | Write an info message to the console. Shorthand for `liftEff $ info x`.
48+
info :: forall eff. String -> Aff (console :: C.CONSOLE | eff) Unit
49+
info = liftEff <<< C.info
50+
51+
-- | Write an info value to the console, using its `Show` instance to produce a
52+
-- | `String`. Shorthand for `liftEff $ infoShow x`.
53+
infoShow :: forall a eff. Show a => a -> Aff (console :: C.CONSOLE | eff) Unit
54+
infoShow = liftEff <<< C.infoShow

test/Test/Main.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import Control.Apply ((*>))
77
import Control.Parallel.Class (parallel, runParallel)
88
import Control.Monad.Aff (Aff, runAff, makeAff, launchAff, later, later', forkAff, forkAll, Canceler(..), cancel, attempt, finally, apathize)
99
import Control.Monad.Aff.AVar (AVAR, makeVar, makeVar', putVar, modifyVar, takeVar, killVar)
10-
import Control.Monad.Aff.Console (log)
10+
import Control.Monad.Aff.Console (CONSOLE, log)
1111
import Control.Monad.Cont.Class (callCC)
1212
import Control.Monad.Eff (Eff)
13-
import Control.Monad.Eff.Console (CONSOLE)
1413
import Control.Monad.Eff.Console (log) as Eff
1514
import Control.Monad.Eff.Exception (EXCEPTION, throwException, error, message, try)
1615
import Control.Monad.Error.Class (throwError)

0 commit comments

Comments
 (0)