module Language.Symantic.Transforming.Beta where
import Language.Symantic.Transforming.Trans
import Language.Symantic.Compiling.Term
data BetaT term a where
BetaT_Unk :: term a -> BetaT term a
BetaT_Lam1 :: (BetaT term a -> BetaT term b) -> BetaT term (a -> b)
instance Sym_Lambda term => Trans (BetaT term) where
type UnT (BetaT term) = term
trans = BetaT_Unk
unTrans (BetaT_Unk t) = t
unTrans (BetaT_Lam1 f) = lam1 $ unTrans . f . trans
instance Sym_Lambda term => Sym_Lambda (BetaT term) where
lam1 = BetaT_Lam1
app (BetaT_Lam1 f) = f
app f = trans2 app f
let_ x f = trans $ let_ (unTrans x) (unTrans . f . trans)
betaT :: Trans (BetaT term) => BetaT term a -> term a
betaT = unTrans