<commit_before>import Control.Concurrent
import Control.Monad

-- -----------------------------------------------------------------------------

-- <<Logger
data Logger = Logger (MVar LogCommand)

data LogCommand = Message String | Stop (MVar ())
-- >>

-- <<initLogger
initLogger :: IO Logger
initLogger = do
  m <- newEmptyMVar
  let l = Logger m
  forkIO (logger l)
  return l
-- >>

-- <<logger
logger :: Logger -> IO ()
logger (Logger m) = forever $ do
  cmd <- takeMVar m
  case cmd of
    Message msg ->
      putStrLn msg
    Stop s -> do 
      putStrLn "logger: stop"
      putMVar s ()
-- >><commit_msg>make it stop properly<commit_after>import Control.Concurrent
import Control.Monad

-- -----------------------------------------------------------------------------

-- <<Logger
data Logger = Logger (MVar LogCommand)

data LogCommand = Message String | Stop (MVar ())
-- >>

-- <<initLogger
initLogger :: IO Logger
initLogger = do
  m <- newEmptyMVar
  let l = Logger m
  forkIO (logger l)
  return l
-- >>

-- <<logger
logger :: Logger -> IO ()
logger (Logger m) = loop
 where
  loop = do
    cmd <- takeMVar m
    case cmd of
      Message msg -> do
        putStrLn msg
        loop
      Stop s -> do
        putStrLn "logger: stop"
        putMVar s ()
-- >>
{'fraction_non_alphanumeric': 0.22884012539184953, 'fraction_numerical': 0.0, 'mean_word_length': 1.6061224489795918, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '5574671', 'n_tokens_mistral': 374, 'n_tokens_neox': 368, 'n_words': 127}