2

我正在玩Twitch库:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell   #-}
module Main where

import Twitch
import Data.Default
import Turtle.Prelude
import RIO

main :: IO ()
main = do
        print "hi"
        let p = "C:\\Users\\unicorn\\programming\\listenerDir" 
        print "before" 
        liftIO $ runWithConfig p ((\c -> c {dirs=[p]}) def) $ do -- marked
          "*.csv" |> \f -> print f                               -- marked
        print "here"
        return ()

当我编译并运行上面的程序时没有liftIO ...(所以省略了标记的行)调用它运行良好并打印消息。(但显然,文件侦听器没有注册和运行,所以这不是预期的结果。)

但是,当按原样编译和运行时,它什么也不做,甚至打印hibefore. 知道为什么会这样吗?

我试图遵循图书馆的例子,但我不知道为什么它只是挂起。


更新:

显然它与我为 def 配置所做的 dirs 替换有关

更新:

我也尝试过以下方式:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell   #-}
module Main where

import Twitch
import Data.Default
import Turtle.Prelude
import RIO
import System.IO.Unsafe
import System.FilePath.Windows

main :: IO ()
main = do
        let p   = "C:\\" </> "Users" </> "unicorn" </> "programming" </> "simpleUID" </> "lib_app_setup" </> "kofax-valet" </> "testingDir" 
            ops = Options LogToStdout Nothing (Just p) False DebounceDefault 0 300 False
        print "starting"
        print p 
        defaultMainWithOptions ops $ do
          "*.csv" > \f -> print f 

结果相同

在源代码中查找它defaultMainWithOptions也应该将内容打印到标准输出;但这也不会发生...

仅供参考:我在reddit上问了这个问题,但没有得到答案,所以我怀疑一个更大的问题可能不仅仅是我对图书馆不熟悉,因此将其发布在这里

更新: 这是cabal run第二个代码的完整输出:

unicorn@LAPTOP ~/programming/haskell/listenerTest
$ cabal run
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - listenerTest-0.1.0.0 (exe:listenerTest) (file Main.hs changed)
Preprocessing executable 'listenerTest' for listenerTest-0.1.0.0..
Building executable 'listenerTest' for listenerTest-0.1.0.0..
[1 of 1] Compiling Main             
( Main.hs, C:\Users\unicorn\programming\haskell\listenerTest\dist-newstyle
\build\x86_64-windows\ghc-8.10.1\listenerTest-0.1.0.0\x\listenerTest\build
\listenerTest\listenerTest-tmp\Main.o )
Linking C:\Users\unicorn\programming\haskell\listenerTest\dist-newstyle\build
\x86_64-windows\ghc-8.10.1\listenerTest-0.1.0.0\x\listenerTest\build
\listenerTest\listenerTest.exe ...





unicorn@LAPTOP ~/programming/haskell/listenerTest
$

之后我不得不 Ctrl+c 然后也杀死任务

4

0 回答 0