<commit_before>-- | This module provides 'EventWriterT', the standard implementation of
-- 'EventWriter'.
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
#ifdef USE_REFLEX_OPTIMIZER
{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
#endif
module Reflex.EventWriter
  ( EventWriterT (..)
  , runEventWriterT
  , EventWriter(..)
  ) where

import Reflex.Class
import Reflex.Host.Class
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.TriggerEvent.Class

import Control.Monad.Exception
import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.Ref
import Control.Monad.State.Strict
import Data.Dependent.Map (DMap, DSum (..))
import qualified Data.Dependent.Map as DMap
import Data.Functor.Misc
import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe
import Data.Semigroup
import Data.Some (Some)
import qualified Data.Some as Some
import Data.Tuple
import Data.Unique.Tag

-- | 'MonadEventWriter' efficiently collects 'Event' values using 'tellEvent'
-- and combines them monoidally to provide an 'Event' result.
class (Monad m, Monoid w) => EventWriter t w m | m -> t w where
  tellEvent :: Event t w -> m ()

-- | A basic implementation of 'EventWriter'.
newtype EventWriterT t w m a = EventWriterT { unEventWriterT :: StateT [Event t w] m a }
  deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadException)

-- | Run a 'EventWriterT' action.
runEventWriterT
    :: (Reflex t, Monad m, Semigroup w)<commit_msg>Fix stray MonadEventWriter mention<commit_after>-- | This module provides 'EventWriterT', the standard implementation of
-- 'EventWriter'.
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
#ifdef USE_REFLEX_OPTIMIZER
{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
#endif
module Reflex.EventWriter
  ( EventWriterT (..)
  , runEventWriterT
  , EventWriter(..)
  ) where

import Reflex.Class
import Reflex.Host.Class
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.TriggerEvent.Class

import Control.Monad.Exception
import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.Ref
import Control.Monad.State.Strict
import Data.Dependent.Map (DMap, DSum (..))
import qualified Data.Dependent.Map as DMap
import Data.Functor.Misc
import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe
import Data.Semigroup
import Data.Some (Some)
import qualified Data.Some as Some
import Data.Tuple
import Data.Unique.Tag

-- | 'EventWriter' efficiently collects 'Event' values using 'tellEvent'
-- and combines them monoidally to provide an 'Event' result.
class (Monad m, Monoid w) => EventWriter t w m | m -> t w where
  tellEvent :: Event t w -> m ()

-- | A basic implementation of 'EventWriter'.
newtype EventWriterT t w m a = EventWriterT { unEventWriterT :: StateT [Event t w] m a }
  deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadException)

-- | Run a 'EventWriterT' action.
runEventWriterT
    :: (Reflex t, Monad m, Semigroup w)
{'fraction_non_alphanumeric': 0.11403508771929824, 'fraction_numerical': 0.0005482456140350877, 'mean_word_length': 4.631172839506172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4089293', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1201, 'n_words': 334}