module Language.Syntactic.TypeRep where
import qualified Data.Typeable as Typeable
import Language.Syntactic
import Language.Syntactic.Functional
import Language.Syntactic.Functional.Sharing
import Data.TypeRep
import Data.TypeRep.Types.Basic
mkVarSym :: Witness Typeable.Typeable t t =>
TypeRep t a -> Name -> BindingT (Full a)
mkVarSym t v | Dict <- wit pDataTypeable t = VarT v
mkLamSym :: Witness Typeable.Typeable t t
=> TypeRep t a -> TypeRep t b -> Name
-> BindingT (b :-> Full (a -> b))
mkLamSym ta _ v | Dict <- wit pDataTypeable ta = LamT v
injTR :: (sub :<: sup, Typeable t (DenResult sig)) =>
sub sig -> AST (sup :&: TypeRep t) sig
injTR s = Sym (inj s :&: typeRep)
smartSymTR
:: ( Signature sig
, supT ~ (sup :&: TypeRep t)
, f ~ SmartFun supT sig
, sig ~ SmartSig f
, supT ~ SmartSym f
, sub :<: sup
, Typeable t (DenResult sig)
)
=> sub sig -> f
smartSymTR s = smartSym' (inj s :&: typeRep)
sugarSymTR
:: ( Signature sig
, supT ~ (sup :&: TypeRep t)
, fi ~ SmartFun supT sig
, sig ~ SmartSig fi
, supT ~ SmartSym fi
, SyntacticN f fi
, sub :<: sup
, Typeable t (DenResult sig)
)
=> sub sig -> f
sugarSymTR = sugarN . smartSymTR
defaultInterfaceTypeRep :: forall binding sym symT t
. ( BindingT :<: sym
, Let :<: sym
, symT ~ (sym :&: TypeRep t)
, FunType :<: t
, TypeEq t t
, Witness Typeable.Typeable t t
)
=> (forall a b . ASTF symT a -> ASTF symT b -> Bool)
-> (forall a . ASTF symT a -> Bool)
-> CodeMotionInterface symT
defaultInterfaceTypeRep = defaultInterfaceDecor typeEq funType mkVarSym mkLamSym