module Language.Embedded.Expression where
import Data.Typeable
#if __GLASGOW_HASKELL__ >= 800
import GHC.Types (Constraint)
#else
import GHC.Prim (Constraint)
#endif
import Language.C.Quote.C (ToIdent (..))
type VarId = String
class FreeExp exp
where
type FreePred exp :: * -> Constraint
constExp :: FreePred exp a => a -> exp a
varExp :: FreePred exp a => VarId -> exp a
data Val a
= ValComp VarId
| ValRun a
deriving Typeable
instance ToIdent (Val a) where toIdent (ValComp r) = toIdent r
valToExp :: (FreeExp exp, FreePred exp a) => Val a -> exp a
valToExp (ValComp v) = varExp v
valToExp (ValRun a) = constExp a
class FreeExp exp => EvalExp exp
where
evalExp :: exp a -> a