Haskell Twitch Library not working as expected

83 Views Asked by At

I am playing around with the Twitch library:

{-# 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 ()

when i compile and run the above program without the liftIO ... (so leaving out the marked lines) call it runs fine and prints the messages. (but then obviously, the file listener is not registered and running, so it is not the desired outcome.)

However, when compiled and run as is, it doesn't do anything, not even printing hi and before. any idea why that is the case here?

I have tried to follow the examples of the library but I can't figure out why it just hangs.


UPDATE:

apparently it has something to do with the dirs replacement I am doing for the def configuration

UPDATE:

I have also tried it the following way:

{-# 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 

with the same result

looking it up in the source, defaultMainWithOptions should also print stuff to stdout; but that doesn't happen either...

fyi: I asked this question on reddit but didn't get an answer there, so I suspected a bigger problem that might not be just my unfamiliarity with the library and therefore posted it here

Update: this is the full output of cabal run for the second code:

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
$

afterwards i had to Ctrl+c and then also kill the task

0

There are 0 best solutions below