@@ -37,6 +37,9 @@ module Obelisk.Route.Frontend
37 , maybeRoute
37 , maybeRoute
38 , maybeRoute_
38 , maybeRoute_
39 , maybeRouted
39 , maybeRouted
40 , runRouteViewT
43 , runRouteViewT
41 , SetRouteT(..)
44 , SetRouteT(..)
42 , SetRoute(..)
45 , SetRoute(..)
@@ -56,6 +59,7 @@ import Obelisk.Route
56import Control.Category (Category (..), (.))
59import Control.Category (Category (..), (.))
57import Control.Category.Cartesian
60import Control.Category.Cartesian
58import Control.Lens hiding (Bifunctor, bimap, universe, element)
61import Control.Lens hiding (Bifunctor, bimap, universe, element)
62+import Control.Monad ((<=<))
59import Control.Monad.Fix
63import Control.Monad.Fix
60import Control.Monad.Primitive
64import Control.Monad.Primitive
61import Control.Monad.Ref
65import Control.Monad.Ref
@@ -204,6 +208,20 @@ maybeRoute f = factorRouted $ strictDynWidget $ \(c :=> r') -> do
204 runRoutedT (f c) r'
208 runRoutedT (f c) r'
212+ :: (MonadFix m, MonadHold t m, Adjustable t m)
215+ -> RoutedT t (Either l r) m ()
216+eitherRoute_ l r = eitherRouted $ strictDynWidget_ $ either (runRoutedT l) (runRoutedT r)
219+ :: (MonadFix m, MonadHold t m, Adjustable t m)
222+ -> RoutedT t (Either l r) m (Dynamic t a)
223+eitherRoute l r = eitherRouted $ strictDynWidget $ either (runRoutedT l) (runRoutedT r)
207dsumValueCoercion :: Coercion f g -> Coercion (DSum k f) (DSum k g)
225dsumValueCoercion :: Coercion f g -> Coercion (DSum k f) (DSum k g)
208dsumValueCoercion Coercion = Coercion
226dsumValueCoercion Coercion = Coercion
@@ -220,6 +238,9 @@ maybeRouted r = RoutedT $ ReaderT $ \d -> do
220 d' <- maybeDyn d
238 d' <- maybeDyn d
221 runRoutedT r d'
239 runRoutedT r d'
241+eitherRouted :: (Reflex t, MonadFix m, MonadHold t m) => RoutedT t (Either (Dynamic t a) (Dynamic t b)) m c -> RoutedT t (Either a b) m c
242+eitherRouted r = RoutedT $ ReaderT $ runRoutedT r <=< eitherDyn
223-- | WARNING: The input 'Dynamic' must be fully constructed when this is run
244-- | WARNING: The input 'Dynamic' must be fully constructed when this is run
224strictDynWidget :: (MonadSample t m, MonadHold t m, Adjustable t m) => (a -> m b) -> RoutedT t a m (Dynamic t b)
245strictDynWidget :: (MonadSample t m, MonadHold t m, Adjustable t m) => (a -> m b) -> RoutedT t a m (Dynamic t b)
225strictDynWidget f = RoutedT $ ReaderT $ \r -> do
246strictDynWidget f = RoutedT $ ReaderT $ \r -> do