Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "no instance for YesodDispatch" error when using warp

Shalom! I have written the following program using Yesod:

main = warp 2060 $
  onStatic "home" (dispatchTo $ return $ h1 $ toHtml "Sheepfold")

But when I run it, I get the following error:

No instance for (YesodDispatch
                   (Control.Monad.Trans.Writer.Lazy.Writer LiteApp ()))
  arising from a use of `warp'
Possible fix:
  add an instance declaration for
  (YesodDispatch (Control.Monad.Trans.Writer.Lazy.Writer LiteApp ()))
In the expression: warp 2060
In the expression:
  warp 2060
  $ onStatic "home" (dispatchTo $ return $ h1 $ toHtml "Sheepfold")
In an equation for `main':
    main
      = warp 2060
        $ onStatic "home" (dispatchTo $ return $ h1 $ toHtml "Sheepfold")

Can anyone help?

like image 666
user1023733 Avatar asked Mar 31 '26 18:03

user1023733


1 Answers

You need to use a call to liteApp. See this example for a demonstration.

like image 146
Michael Snoyman Avatar answered Apr 03 '26 08:04

Michael Snoyman