やりたいこと
webサイトのトップページにアクセスされたら、index.htmlを表示させ、サーバー起動のターミナル画面に標準出力で"this is test"を出力させたい。
{-# LANGUAGE OverloadedStrings #-} import Web.Scotty import System.Process import System.Cmd import GHC.IO.Exception web :: ScottyM () web = do get "/" showTop showTop :: ActionM () showTop = do system "echo this is test" setHeader "Content-Type" "text/html" file "web/index.html" main :: IO () main = scotty 3000 web
できていないこと
• Couldn't match type ‘IO’ with ‘Web.Scotty.Internal.Types.ActionT text-1.2.3.1:Data.Text.Internal.Lazy.Text IO’ Expected type: Web.Scotty.Internal.Types.ActionT text-1.2.3.1:Data.Text.Internal.Lazy.Text IO ExitCode Actual type: IO ExitCode • In a stmt of a 'do' block: system "echo this is test" In the expression: do system "echo this is test" setHeader "Content-Type" "text/html" file "web/index.html" In an equation for ‘showTop’: showTop = do system "echo this is test" setHeader "Content-Type" "text/html" file "web/index.html"
system "echo this is test" の型が IO ExitCode
でも、上記を使っている部分の関数の型が Web.Scotty.Internal.Types.ActionT~~となっており、違うと言っている?
質問
showTop関数の中で system "echo this is test" を実行させるためにはどのような手法をとればいいのかご教示いただけませんでしょうか?
回答1件
あなたの回答
tips
プレビュー