<commit_before>{-# LANGUAGE BangPatterns #-}


module SimpleStore.Cell.Internal
    (
    ioFoldRListT
    ) where


import           Control.Concurrent.STM
import qualified ListT


ioFoldRListT :: ListT.MonadTransUncons t =>
       (a -> b -> b) -> b -> t STM a -> IO b
ioFoldRListT fcn !seed lst = ioFoldRListT' fcn (return seed) lst 



ioFoldRListT'
  :: ListT.MonadTransUncons t =>
     (a -> b -> b) -> IO b -> t STM a -> IO b
ioFoldRListT' fcn !iseed lst = do 
  (ma,mlst) <- atomically $ do
                   ma <- ListT.head lst 
                   mlst <- ListT.tail lst
                   return (ma,mlst)
  seed <- iseed                 
  case ma of
   Nothing -> return seed
   Just val ->  do
     maybe (return seed)
           (ioFoldRListT' fcn (return $ fcn val seed))
           mlst                 
<commit_msg>Added Traverse over io after calling STM<commit_after>{-# LANGUAGE BangPatterns #-}


module SimpleStore.Cell.Internal
    (
    ioFoldRListT
    ) where


import           Control.Concurrent.STM
import qualified ListT
import Control.Monad

ioFoldRListT :: ListT.MonadTransUncons t =>
       (a -> b -> b) -> b -> t STM a -> IO b
ioFoldRListT fcn !seed lst = ioFoldRListT' fcn (return seed) lst 



ioFoldRListT'
  :: ListT.MonadTransUncons t =>
     (a -> b -> b) -> IO b -> t STM a -> IO b
ioFoldRListT' fcn !iseed lst = do 
  (ma,mlst) <- atomically $ do
                   ma <- ListT.head lst 
                   mlst <- ListT.tail lst
                   return (ma,mlst)
  seed <- iseed                 
  case ma of
   Nothing -> return seed
   Just val ->  do
     maybe (return seed)
           (ioFoldRListT' fcn (return $ fcn val seed))
           mlst                 



ioTraverseListT :: ListT.MonadTransUncons t =>
                                          (a -> IO b) ->  
                                          t STM a -> 
                                          IO b
ioTraverseListT fcn stmA = ioTraverseListT' fcn stmA 


ioTraverseListT' fcn stmListT = do 
          (ma,mlst) <- atomically $ do
                         ma <- ListT.head stmListT
                         mlst <- ListT.tail stmListT
                         return (ma,mlst)
          case ma  of
            Nothing -> mzero
            (Just a) -> fcn a

{'fraction_non_alphanumeric': 0.09329829172141918, 'fraction_numerical': 0.0, 'mean_word_length': 1.3791666666666667, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '104956', 'n_tokens_mistral': 776, 'n_tokens_neox': 726, 'n_words': 215}