module DDC.Core.Simplifier.Base
(
Simplifier(..)
, Transform(..)
, InlinerTemplates
, NamedRewriteRules
, TransformResult(..)
, TransformInfo(..)
, NoInformation
, resultDone)
where
import DDC.Core.Simplifier.Result
import DDC.Core.Transform.Rewrite.Rule
import DDC.Core.Transform.Namify
import DDC.Core.Exp
import DDC.Type.Env
import DDC.Base.Pretty
import qualified DDC.Core.Transform.Snip as Snip
import qualified DDC.Core.Transform.Eta as Eta
import qualified DDC.Core.Transform.Beta as Beta
import qualified DDC.Core.Transform.FoldCase as FoldCase
data Simplifier s a n
= Trans (Transform s a n)
| Seq (Simplifier s a n) (Simplifier s a n)
| Fix Int (Simplifier s a n)
instance Monoid (Simplifier s a n) where
mempty = Trans Id
mappend = Seq
instance Pretty (Simplifier s a n) where
ppr ss
= case ss of
Seq s1 s2
-> ppr s1 <+> text ";" <+> ppr s2
Fix i s
-> text "fix" <+> int i <+> ppr s
Trans t1
-> ppr t1
data Transform s a n
= Id
| Anonymize
| Beta Beta.Config
| Bubble
| Elaborate
| Eta Eta.Config
| Flatten
| Forward
| FoldCase FoldCase.Config
| Inline
{
transInlineDef :: InlinerTemplates a n }
| Lambdas
| Namify
{
transMkNamifierT :: Env n -> Namifier s n
, transMkNamifierX :: Env n -> Namifier s n }
| Prune
| Rewrite
{
transRules :: NamedRewriteRules a n }
| Snip Snip.Config
type InlinerTemplates a n
= (n -> Maybe (Exp a n))
type NamedRewriteRules a n
= [(String, RewriteRule a n)]
instance Pretty (Transform s a n) where
ppr ss
= case ss of
Id -> text "Id"
Anonymize -> text "Anonymize"
Beta{} -> text "Beta"
Bubble -> text "Bubble"
Elaborate -> text "Elaborate"
Eta{} -> text "Eta"
Flatten -> text "Flatten"
Forward -> text "Forward"
FoldCase{} -> text "FoldCase"
Inline{} -> text "Inline"
Lambdas{} -> text "Lambdas"
Namify{} -> text "Namify"
Prune -> text "Prune"
Rewrite{} -> text "Rewrite"
Snip{} -> text "Snip"