Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MonadRouted #55

Open
billrockx opened this issue Oct 3, 2018 · 1 comment
Open

Using MonadRouted #55

billrockx opened this issue Oct 3, 2018 · 1 comment

Comments

@billrockx
Copy link

How to use routeApp to add routing to my webpage.

testApp :: MonadWidget t m => m ()
testApp = do
  routeApp "app" $ do
    withPathSegment go
  pure ()
  where
    go ::  (MonadWidget t m, MonadRouted t m) => Dynamic t (Maybe PathSegment) -> m ()
    go dPathSeg = do
      (dyn . ffor dPathSeg) $ \ps -> do
        case maybe "a" id ps of
          "a" -> do
            evt <- button "switch to View B"
            redirectInternal $ ("b" <$ evt)
            text "View A"
          "b" -> do
            evt <- button "switch to View A"
            redirectInternal $ ("a" <$ evt)
            text "View B"
      pure ()

I get this error while running the code:

Could not deduce (NotReady t (RouteT t m))
        arising from a use of ‘go’
      from the context: MonadWidget t m
        bound by the type signature for:
                   testApp :: MonadWidget t m => m ()

@mightybyte
Copy link
Member

Ahh, it looks like we need to provide an instance for the new NotReady type class in reflex (https://github.com/reflex-frp/reflex/blob/develop/src/Reflex/NotReady/Class.hs).

However, Obsidian has a new router system they've been working on as a part of Obelisk. The source is here:

https://github.com/obsidiansystems/obelisk/blob/master/lib/route/src/Obelisk/Route.hs

And here is an example of how reflex-frp.org uses it:

https://github.com/reflex-frp/reflex-frp.org/blob/master/common/src/Common/Route.hs

MonadRouted was thrown together pretty quickly to get something usable. The new obelisk routing infrastructure is much more carefully thought out, so I would recommend switching to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants