@@ -80,7 +80,14 @@ run p = runSettings defaultSettings { settingsPort = p }
8080runEnv :: Port -> Application -> IO ()
8181runEnv p app = do
8282 mp <- fmap (lookup "PORT") getEnvironment
83− run (maybe p read mp) app
83+
84+ maybe (run p app) runReadPort mp
85+
86+ where
87+ runReadPort :: String -> IO ()
88+ runReadPort sp = case reads sp of
89+ ((p', _):_) -> run p' app
90+ _ -> fail $ "Invalid value in $PORT: " ++ sp
8491
8592-- | Run an 'Application' with the given 'Settings'.
8693runSettings :: Settings -> Application -> IO ()