natefaubion / purescript-run

An extensible-effects implementation
MIT License
158 stars 14 forks source link

Make Run instance of MonadState? #9

Open esad opened 6 years ago

esad commented 6 years ago

Would it be possible to make Run (state ∷ STATE s | r) instance of MonadState similar to how this has been done for MonadEff and MonadAff? I'm trying to use purescript-run with some lenses inside, and the lens functions (use, assign etc.) expect the state monad in their signatures.

natefaubion commented 6 years ago

Yes, this is possible. We would have to move the state data types into Internal like I did for Choice, and then you could define state :: (s -> Tuple a s) -> Run (state :: STATE s | r) a in terms of get and modify. It's possible we could also just change the representation of the State functor.

artemisSystem commented 4 years ago

I think I remember discussing doing this for State and some other effects in slack a while ago. I remember hearing it kind of defeated the point of extensible effects, so should this be closed?