module Language.Paraiso.OM.DynValue
(
DynValue(..), mkDyn, toDyn, f2d, ToDynable
) where
import Data.Typeable
import qualified Language.Paraiso.OM.Value as Val
import qualified Language.Paraiso.OM.Realm as R
data DynValue = DynValue {realm :: R.Realm, typeRep :: TypeRep} deriving (Eq, Show)
mkDyn :: (R.TRealm r, Typeable c) => r -> c -> DynValue
mkDyn r0 c0 = DynValue (R.tRealm r0) (typeOf c0)
class ToDynable a where
toDyn :: a -> DynValue
instance (R.TRealm r, Typeable c) => ToDynable (Val.Value r c) where
toDyn x = mkDyn (Val.realm x) (Val.content x)
instance (R.TRealm r, Typeable c) => ToDynable (Val.StaticValue r c) where
toDyn (Val.StaticValue r c) = mkDyn r c
f2d :: (Functor f, ToDynable x) => f x -> f DynValue
f2d = fmap toDyn
instance R.Realmable DynValue where
realm = realm