<commit_before>module Control.Effects.Reader where

import Control.Effects
import Data.Typeable

data Reader w a = Reader (w -> a) deriving (Functor, Typeable)

ask :: (Member (Reader a) r, Typeable a) => Eff r a
ask = effect $ Reader return

readerHandler :: w -> Handler (Reader w) r a a
readerHandler _ (Left a) = return a
readerHandler n (Right (Reader k)) = k n<commit_msg>implement Reader.reader. This fixes #5<commit_after>module Control.Effects.Reader where

import Control.Effects
import Data.Typeable

data Reader w a = Reader (w -> a) deriving (Functor, Typeable)

ask :: (Member (Reader a) r, Typeable a) => Eff r a
ask = effect $ Reader return

reader :: (Member (Reader a) r, Typeable a) => (a -> b) -> Eff r b
reader f = effect $ Reader $ return . f

readerHandler :: w -> Handler (Reader w) r a a
readerHandler _ (Left a) = return a
readerHandler n (Right (Reader k)) = k n
{'fraction_non_alphanumeric': 0.11473565804274466, 'fraction_numerical': 0.0011248593925759281, 'mean_word_length': 3.9720670391061454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2242565', 'n_tokens_mistral': 287, 'n_tokens_neox': 274, 'n_words': 123}