Indexed Effects with Purescript-Run

I am wondering if there are any examples anywhere of using Purescript-Run to represent indexed-effects, such as an Indexed State Monad with the state transitions being tracked in the type parameters.

1 Like

I don’t know of a good way to do it with purescript-run as is. Indexed monads have two additional type parameters for tracking transitions, but it’s not immediately clear to me how that applies in general to an extensible type. You would have to consider all possible transitions between all the possible types in your effects. It’s maybe possible that you could index a single functor in your effects like this, and maybe use an alternative bind implementation with rebindable syntax to track it, but you would also have to reinterpret your effect at each bind operation to change the indexed type.

Yea, the idea is basically to add an indexed state effect (using purescript’s record system to track the state changes) to my other Run effects I was considering newtyping Run to add the extra type parameters and then lifting the other Run values into it and leaving them polymorphic in the two indexes. I was just curious if anyone had tried something similar.