diff --git a/src/Effect/Console.js b/src/Effect/Console.js index 1cc2ce0..7a0466e 100644 --- a/src/Effect/Console.js +++ b/src/Effect/Console.js @@ -1,27 +1,27 @@ "use strict"; -exports.log = function (s) { +exports._log = function (s) { return function () { console.log(s); return {}; }; }; -exports.warn = function (s) { +exports._warn = function (s) { return function () { console.warn(s); return {}; }; }; -exports.error = function (s) { +exports._error = function (s) { return function () { console.error(s); return {}; }; }; -exports.info = function (s) { +exports._info = function (s) { return function () { console.info(s); return {}; diff --git a/src/Effect/Console.purs b/src/Effect/Console.purs index 8a00758..2430293 100644 --- a/src/Effect/Console.purs +++ b/src/Effect/Console.purs @@ -5,46 +5,67 @@ import Effect (Effect) import Data.Show (class Show, show) import Data.Unit (Unit) +class IsLog a + +instance isLogString :: IsLog String +instance isLogArray :: IsLog a => IsLog (Array a) + -- | Write a message to the console. -foreign import log - :: String - -> Effect Unit +log :: forall a. IsLog a => a -> Effect Unit +log = _log -- | Write a value to the console, using its `Show` instance to produce a -- | `String`. logShow :: forall a. Show a => a -> Effect Unit logShow a = log (show a) --- | Write an warning to the console. -foreign import warn - :: String +foreign import _log + :: forall a + . a -> Effect Unit +-- | Write an warning to the console. +warn :: forall a. IsLog a => a -> Effect Unit +warn = _warn + -- | Write an warning value to the console, using its `Show` instance to produce -- | a `String`. warnShow :: forall a. Show a => a -> Effect Unit warnShow a = warn (show a) --- | Write an error to the console. -foreign import error - :: String +foreign import _warn + :: forall a + . a -> Effect Unit +-- | Write an error to the console. +error :: forall a. IsLog a => a -> Effect Unit +error = _error + -- | Write an error value to the console, using its `Show` instance to produce a -- | `String`. errorShow :: forall a. Show a => a -> Effect Unit errorShow a = error (show a) --- | Write an info message to the console. -foreign import info - :: String +foreign import _error + :: forall a + . a -> Effect Unit +-- | Write an info message to the console. +info :: forall a. IsLog a => a -> Effect Unit +info = _info + -- | Write an info value to the console, using its `Show` instance to produce a -- | `String`. infoShow :: forall a. Show a => a -> Effect Unit infoShow a = info (show a) +foreign import _info + :: forall a + . a + -> Effect Unit + -- | Start a named timer. foreign import time :: String -> Effect Unit