7

我有以下程序,它在运行时不产生任何输出runhaskell Toy.hs,而是无限期挂起。据我了解,程序应该打印“hi”然后退出。我将不胜感激有关如何调试此类问题的答案和/或建议。我正在使用 github ( github.com/Gabriel439/Haskell-Pipes-Library ) 的 Pipes 4.0.0。

module Toy where

import Pipes
import Control.Monad.State

type Request = String
type Response = String

serveChoice :: Request -> Server Request Response IO ()
serveChoice = forever go
  where go req = do
        lift $ putStrLn req
        respond req

run :: Monad m => () -> Client Request Response (StateT Int m) ()
run () = do
    request "hi"
    return ()

main :: IO ()
main = evalStateT (runEffect $ hoist lift . serveChoice >-> run $ ()) 0
4

1 回答 1

9
于 2013-06-30T02:17:08.757 回答