<commit_before>{-# LANGUAGE PatternGuards, ViewPatterns, MultiParamTypeClasses #-}

module HSE.Util where

import Control.Monad
import Data.Generics
import Data.Generics.PlateData
import Data.List
import Data.Maybe
import Language.Haskell.Exts
import Util


---------------------------------------------------------------------
-- ACCESSOR/TESTER

fromName :: Name -> String
fromName (Ident x) = x
fromName (Symbol x) = x

toName :: String -> Name
toName = Ident

toQName :: String -> QName
toQName = UnQual . toName

opExp :: QOp -> Exp
opExp (QVarOp op) = Var op
opExp (QConOp op) = Con op

moduleDecls :: Module -> [Decl]
moduleDecls (Module _ _ _ _ _ _ xs) = xs

moduleName :: Module -> String
moduleName (Module _ (ModuleName x) _ _ _ _ _) = x

fromParseOk :: ParseResult a -> a
fromParseOk (ParseOk x) = x

fromVar :: Exp -> Maybe QName
fromVar (Var x) = Just x
fromVar _ = Nothing

isVar :: Exp -> Bool
isVar = isJust . fromVar

toVar :: String -> Exp
toVar = Var . UnQual . Ident

isChar :: Exp -> Bool
isChar (Lit (Char _)) = True
isChar _ = False

fromChar :: Exp -> Char
fromChar (Lit (Char x)) = x<commit_msg>Delete unused fromVar/isVar<commit_after>{-# LANGUAGE PatternGuards, ViewPatterns, MultiParamTypeClasses #-}

module HSE.Util where

import Control.Monad
import Data.Generics
import Data.Generics.PlateData
import Data.List
import Data.Maybe
import Language.Haskell.Exts
import Util


---------------------------------------------------------------------
-- ACCESSOR/TESTER

fromName :: Name -> String
fromName (Ident x) = x
fromName (Symbol x) = x

toName :: String -> Name
toName = Ident

toQName :: String -> QName
toQName = UnQual . toName

opExp :: QOp -> Exp
opExp (QVarOp op) = Var op
opExp (QConOp op) = Con op

moduleDecls :: Module -> [Decl]
moduleDecls (Module _ _ _ _ _ _ xs) = xs

moduleName :: Module -> String
moduleName (Module _ (ModuleName x) _ _ _ _ _) = x

fromParseOk :: ParseResult a -> a
fromParseOk (ParseOk x) = x

toVar :: String -> Exp
toVar = Var . UnQual . Ident

isChar :: Exp -> Bool
isChar (Lit (Char _)) = True
isChar _ = False

fromChar :: Exp -> Char
fromChar (Lit (Char x)) = x
{'fraction_non_alphanumeric': 0.170182841068917, 'fraction_numerical': 0.0, 'mean_word_length': 2.750439367311072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '298062', 'n_tokens_mistral': 711, 'n_tokens_neox': 695, 'n_words': 228}