<commit_before>--| Support for logging native javascript objects to the console using
--| the `AsForeign` class.
module Control.Monad.Eff.Console.Foreign
       ( log
       , info
       , warn
       , error) where

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE)
import Control.Semigroupoid ((<<<))
import Data.Foreign (Foreign)
import Data.Foreign.Class (class AsForeign, write)
import Data.Unit (Unit)

-- | Write a message to the native console using `console.log`.
log :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
log = _log <<< write

-- | Write an info message to the native console using `console.info`.
info :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
info = _info <<< write

-- | Write a warning message to the native console using `console.warn`.
warn :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
warn = _warn <<< write

-- | Write an error message to the native console using `console.error`.
error :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
error = _error <<< write

foreign import _log :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _info :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _warn :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _error :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
<commit_msg>rename log => logF, info => infoF, warn => warnF, error => errorF so name clashing doesn't occur with standard Console module<commit_after>--| Support for logging native javascript objects to the console using
--| the `AsForeign` class.
module Control.Monad.Eff.Console.Foreign
       ( logF
       , infoF
       , warnF
       , errorF) where

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE)
import Control.Semigroupoid ((<<<))
import Data.Foreign (Foreign)
import Data.Foreign.Class (class AsForeign, write)
import Data.Unit (Unit)

-- | Write a message to the native console using `console.log`.
logF :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
logF = _log <<< write

-- | Write an info message to the native console using `console.info`.
infoF :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
infoF = _info <<< write

-- | Write a warning message to the native console using `console.warn`.
warnF :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
warnF = _warn <<< write

-- | Write an error message to the native console using `console.error`.
errorF :: forall a e. AsForeign a => a -> Eff (console :: CONSOLE | e) Unit
errorF = _error <<< write

foreign import _log :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _info :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _warn :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit
foreign import _error :: forall e. Foreign -> Eff (console :: CONSOLE | e) Unit

{'fraction_non_alphanumeric': 0.12491649966599866, 'fraction_numerical': 0.0, 'mean_word_length': 3.443620178041543, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5820033', 'n_tokens_mistral': 916, 'n_tokens_neox': 901, 'n_words': 383}