“Yesod devel” fails with fromJust in devel.hs

2019-07-17 16:23发布

问题:

When I run "yesod devel" it says "devel.hs: Maybe.fromJust: Nothing

yesod init # created a project bbbb
...
cabal install && yesod devel
...
Registering bbbb-0.0.0...
Starting development server...
Starting devel application
devel.hs: Maybe.fromJust: Nothing

And the web server is not listening the port (I cannot open the site in my browser)

Does anyone know how to fix this?

My environment:

  • yesod-0.9.4.1
  • The Glorious Glasgow Haskell Compilation System, version 7.0.3
  • Mac OS X 10.6.8

Here is dist/devel.hs, which "yesod init" created:

{-# LANGUAGE PackageImports #-}
import "bbbb" Application (withDevelAppPort)
import Data.Dynamic (fromDynamic)
import Network.Wai.Handler.Warp
    (runSettings, defaultSettings, settingsPort, settingsHost)
import Data.Maybe (fromJust)
import Control.Concurrent (forkIO)
import System.Directory (doesFileExist, removeFile)
import System.Exit (exitSuccess)
import Control.Concurrent (threadDelay)

main :: IO ()
main = do
  putStrLn "Starting devel application"
  wdap <- (return . fromJust . fromDynamic) withDevelAppPort
  forkIO . wdap $ \(port, app) -> runSettings defaultSettings
    { settingsPort = port
    , settingsHost = "0.0.0.0"
    } app
  loop

loop :: IO ()
loop = do
  threadDelay 100000
  e <- doesFileExist "dist/devel-terminate"
  if e then terminateDevel else loop

terminateDevel :: IO ()
terminateDevel = exitSuccess

I uploaded all files in bbbb directory and Application.hs is https://github.com/suztomo/LanguageStudy/blob/master/Haskell/Yesod/bbbb/Application.hs .

回答1:

A shot in the dark answer: check in your cabal file that you're using yesod-default 0.5.



标签: haskell yesod