You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zoom can't (currently) work polymorphically over MonadState. MonadState isn't sufficient for us to be able to swap out the type of state in your monad.
As a somewhat idle aside before I forget:
One option to make this less painful for users is we could make a monad transformer to the supplied monad that switches out the state for the nested context rather than swapping the state type. However, that has a consequence. Right now the correctness of applying zoom to a Traversal hinges on the fact that it can't write to other parts of the state than what is zoomed. That would be lost by the transformer version.
@ekmett What do you mean by “MonadState isn't sufficient for us to be able to swap out the type of state in your monad”? I thought it meant that you can change the type of the state, but it looks like you can't:
>flip execState (1::Int, 2) $ zoom _1 $id%=show<interactive>:4:45:Couldn't match type‘Int’ with ‘[Char]’
arising from a functional dependency between:
constraint ‘MonadStateString (StateTIntIdentity)’
arising from a use of‘%=’instance‘MonadStates (StateTsm)’at<nolocationinfo>In the second argument of‘($)’, namely ‘id%=show’In the second argument of‘($)’, namely ‘zoom _1 $id%=show’In the expression:flip execState (1::Int, 2) $ zoom _1 $id%=show
Or did you just mean that with MonadState we'd only be able to use lenses of the type Lens' s s?
I have a function in which I'm trying to use
zoom
like so:Acid.Update
is an instance ofMonadState
. However I get the following error:But if I change the type signature to
the function compiles just fine.
The text was updated successfully, but these errors were encountered: