considerazione alcuni trasformatori monade impilano, diconoCome forcella all'interno monade trasformatore
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
...
newtype J = J { runJ :: ErrorT Foo (StateT Bar IO) a } deriving (Applicative, Functor, etc)
e alcune funzioni in J
:
peekNextQuux :: J Quux
peekNextQuux = ...
withJ :: J a -> IO (Either Foo a)
withJ = ...
Poi mi son trovata in J
contesto. Posso scrivere
f = withJ $ peekNextQuux >>= liftIO . print
Ora voglio sbirciare e quuxes stampa all'interno thread separato all'interno J
contesto
g = withJ . liftIO . forkIO . forever $ peekNextQuux >>= liftIO . print
che ovviamente non funzionerà. Immagino che ci sia un modo per risolvere un problema così semplice, ma non riesco a capirlo.
Grazie, ha funzionato. –