module Language.EO.Phi.Rules.RunYegor where
import Language.EO.Phi.Dataize.Context
import Language.EO.Phi.Rules.Common
import Language.EO.Phi.Rules.Yaml qualified as Yaml
import Language.EO.Phi.Syntax (printTree)
import Language.EO.Phi.Syntax.Abs
import System.IO.Unsafe (unsafePerformIO)
runWithYegorRules :: (Context -> Object -> Object) -> Object -> IO ()
runWithYegorRules :: (Context -> Object -> Object) -> Object -> IO ()
runWithYegorRules Context -> Object -> Object
f Object
obj = String -> IO ()
putStrLn (Object -> String
forall a. Print a => a -> String
printTree (Context -> Object -> Object
f ([NamedRule] -> Object -> Context
defaultContext [NamedRule]
yegorRules Object
obj) Object
obj))
yegorRuleSet :: Yaml.RuleSet
{-# NOINLINE yegorRuleSet #-}
yegorRuleSet :: RuleSet
yegorRuleSet =
IO RuleSet -> RuleSet
forall a. IO a -> a
unsafePerformIO (IO RuleSet -> RuleSet) -> IO RuleSet -> RuleSet
forall a b. (a -> b) -> a -> b
$
String -> IO RuleSet
Yaml.parseRuleSetFromFile String
"eo-phi-normalizer/test/eo/phi/rules/yegor.yaml"
yegorRules :: [NamedRule]
yegorRules :: [NamedRule]
yegorRules = (Rule -> NamedRule) -> [Rule] -> [NamedRule]
forall a b. (a -> b) -> [a] -> [b]
map Rule -> NamedRule
Yaml.convertRuleNamed (RuleSet -> [Rule]
Yaml.rules RuleSet
yegorRuleSet)