module Web.Route.Invertible.Dynamics
( Dynamics
, DynamicState
, DynamicResult
, getDynamic
) where
import Data.Dynamic (Dynamic, fromDyn)
import Data.Typeable (Typeable)
import Control.Monad.Trans.State (StateT(..), State)
unconsState' :: State [a] a
unconsState' = StateT $ \(~(x:l)) -> return (x, l)
type Dynamics = [Dynamic]
type DynamicState = State Dynamics
type DynamicResult a = (Dynamics, a)
getDynamic :: Typeable a => DynamicState a
getDynamic = (`fromDyn` error "Web.Route.Invertible.getDynamic: internal type error") <$> unconsState'