
20 Nov
2019
20 Nov
'19
6:08 p.m.
Is there a way to have a function of type (a -> b) -> State a c -> State b c ? In the particular case of interest, I am interested in is actually b -> State a c -> (State (a,b) c), which is of course a special case of the above. This matches 'first' on Data.Bifunctor, but State is not a Bifunctor. Nor a Profunctor, AFAIK. Use case: a Stateful computation where a local sub-computation needs more (local) state that will be, in-time, de-allocated. I guess the usual solution is probably to use 2 stacked State, but I'm curious if there's another way. Jacques