<commit_before>module Pyrec where

import           Control.Monad.Writer

import           Text.Parsec.Error

import qualified Pyrec.AST        as A

import qualified Pyrec.IR.Desugar as D
import qualified Pyrec.IR.Check   as C
import qualified Pyrec.IR.Core    as R

import qualified Pyrec.Parse      as P
import qualified Pyrec.Desugar    as D
import qualified Pyrec.Check      as C
import qualified Pyrec.Report     as R
import qualified Pyrec.Compile    as O
import qualified Pyrec.Emit       as E

infixr 9 <.>
(<.>) :: Functor f => (a1 -> b) -> (a -> f a1) -> a -> f b
a <.> b = fmap a . b

checkEmit :: C.Env -> D.Expr -> Writer R.Errors String
checkEmit foreignEnv = E.emit <.> O.compile <.> R.report . C.tc foreignEnv

desugarEmit :: C.Env -> A.Module -> Writer R.Errors String
desugarEmit foreignEnv = checkEmit foreignEnv <=< (mapWriter $ fmap . fmap . fmap $ R.Earlier) . D.convModule

parseEmit :: C.Env -> String -> Either ParseError (Writer R.Errors String)
parseEmit foreignEnv = desugarEmit foreignEnv <.> P.parseString P.program<commit_msg>Removed unneeded import in Pyrec.hs<commit_after>module Pyrec where

import           Control.Monad.Writer

import           Text.Parsec.Error

import qualified Pyrec.AST        as A

import qualified Pyrec.IR.Desugar as D
import qualified Pyrec.IR.Core    as R

import qualified Pyrec.Parse      as P
import qualified Pyrec.Desugar    as D
import qualified Pyrec.Check      as C
import qualified Pyrec.Report     as R
import qualified Pyrec.Compile    as O
import qualified Pyrec.Emit       as E

infixr 9 <.>
(<.>) :: Functor f => (a1 -> b) -> (a -> f a1) -> a -> f b
a <.> b = fmap a . b

checkEmit :: C.Env -> D.Expr -> Writer R.Errors String
checkEmit foreignEnv = E.emit <.> O.compile <.> R.report . C.tc foreignEnv

desugarEmit :: C.Env -> A.Module -> Writer R.Errors String
desugarEmit foreignEnv = checkEmit foreignEnv <=< (mapWriter $ fmap . fmap . fmap $ R.Earlier) . D.convModule

parseEmit :: C.Env -> String -> Either ParseError (Writer R.Errors String)
parseEmit foreignEnv = desugarEmit foreignEnv <.> P.parseString P.program
{'fraction_non_alphanumeric': 0.10433539780848022, 'fraction_numerical': 0.0028585040495474035, 'mean_word_length': 2.8817005545286505, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 39, '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': '4178441', 'n_tokens_mistral': 671, 'n_tokens_neox': 679, 'n_words': 232}