[Haskell-beginners] how does hgearman-worker work?

info at maximka.de info at maximka.de
Thu Apr 6 15:37:22 UTC 2017


A while ago I asked similar question about hgearman client. With help I got in the List (https://mail.haskell.org/pipermail/beginners/2017-March/017435.html) and I implemented a gearman client in Haskell. (here the implementation http://stackoverflow.com/questions/42774191/how-does-hgearman-client-work)

Unfortunately I need again some help be implementation of gearman worker.

I post here only the snippet with the badly implemented code in hope to find again some help. (Complete implementation: http://stackoverflow.com/questions/43155857/how-does-hgearman-worker-work)

Right gc -> do
  (res, _) <- flip S.runStateT gc $ do
    g <- (W.registerWorker name func)
    t <- W.runWorker gc (return ())
    return t >> return  ()

  return res

This throws exception:
Couldn't match expected type `S.StateT
                                Network.Gearman.Internal.GearmanClient IO a0'
                with actual type `IO GHC.Conc.Sync.ThreadId'
    In a stmt of a 'do' block: t <- W.runWorker gc (return ())
    In the second argument of `($)', namely
      `do { g <- (W.registerWorker name func);
            t <- W.runWorker gc (return ());
            return t >> return () }


What do I wrong with W.runWorker gc (return ())?

runWorker :: GearmanClient -> Gearman () -> IO ThreadId
https://hackage.haskell.org/package/hgearman-0.1.0.2/docs/Network-Gearman-Worker.html

Best regards,
Alexei


More information about the Beginners mailing list