
Hello, I am using monad-coroutine https://hackage.haskell.org/package/monad-coroutine package and have something like Coroutine (Await Int) (State MyState) Int (simplified version, for example purpose). MyState is deeply nested and I do a lot of modifications in it. Previously (with different data types) I was able to use zoom from lens https://hackage.haskell.org/package/lensin order to simplify the typing/view of code which operates on some subtree of the state, e.g.: zoom (company.assets) $ do something.a = someComputation anotherthing.b = False this.that = "someString" The problem I am having is that I cannot come up with instance Zoom for the Coroutine and was wondering if anyone is able to help me with that? Best regards, Konstantin

Hello, Just a thought: maybe it would be easier to write a MFunctor ( https://hackage.haskell.org/package/mmorph-1.0.6/docs/Control-Monad-Morph.ht...) instance, and then use (hoist . zoom $ company.assets)? Best regards, Marcin Mrotek

On 03/11/2016 02:35 AM, Konstantin Saveljev wrote:
Hello,
I am using monad-coroutine https://hackage.haskell.org/package/monad-coroutine package and have something like Coroutine (Await Int) (State MyState) Int (simplified version, for example purpose).
MyState is deeply nested and I do a lot of modifications in it. Previously (with different data types) I was able to use zoom from lens https://hackage.haskell.org/package/lensin order to simplify the typing/view of code which operates on some subtree of the state, e.g.:
|zoom (company.assets) $ dosomething.a = someComputation anotherthing.b = False this.that = "someString" | The problem I am having is that I cannot come up with instance Zoom for the Coroutine and was wondering if anyone is able to help me with that?
I don't know if it gets you instance Zoom, but you can combine zoom with mapMonad to dive into a field of your state. https://hackage.haskell.org/package/monad-coroutine-0.9.0.2/docs/Control-Mon...
participants (3)
-
Konstantin Saveljev
-
Marcin Mrotek
-
Mario Blažević