Skip to content

Commit 9b0318c

Browse files
committed
Added logAny and errorAny
1 parent a7becf0 commit 9b0318c

5 files changed

Lines changed: 55 additions & 0 deletions

File tree

docs/Control/Monad/Eff/Console.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Module Control.Monad.Eff.Console
22

3+
Console-related functions and effect type.
4+
35
#### `CONSOLE`
46

57
``` purescript
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Module Control.Monad.Eff.Console.Unsafe
2+
3+
Unsafe functions to display arbitrary values.
4+
5+
#### `logAny`
6+
7+
``` purescript
8+
logAny :: forall a eff. a -> Eff (console :: CONSOLE | eff) Unit
9+
```
10+
11+
Write a runtime representation of a value to the console.
12+
13+
#### `errorAny`
14+
15+
``` purescript
16+
errorAny :: forall a eff. a -> Eff (console :: CONSOLE | eff) Unit
17+
```
18+
19+
Write an error with a runtime representation of a value to the console.
20+
21+

src/Control/Monad/Eff/Console.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- | Console-related functions and effect type.
12
module Control.Monad.Eff.Console where
23

34
import Prelude
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* global exports, console */
2+
"use strict";
3+
4+
// module Control.Monad.Eff.Console.Unsafe
5+
6+
exports.logAny = function (s) {
7+
return function () {
8+
console.log(s);
9+
return {};
10+
};
11+
};
12+
13+
exports.errorAny = function (s) {
14+
return function () {
15+
console.error(s);
16+
return {};
17+
};
18+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- | Unsafe functions to display arbitrary values.
2+
module Control.Monad.Eff.Console.Unsafe where
3+
4+
import Prelude
5+
6+
import Control.Monad.Eff
7+
import Control.Monad.Eff.Console (CONSOLE())
8+
9+
-- | Write a runtime representation of a value to the console.
10+
foreign import logAny :: forall a eff. a -> Eff (console :: CONSOLE | eff) Unit
11+
12+
-- | Write an error with a runtime representation of a value to the console.
13+
foreign import errorAny :: forall a eff. a -> Eff (console :: CONSOLE | eff) Unit

0 commit comments

Comments
 (0)