[Haskell-cafe] Transforming from on State-transformer to another
carette at mcmaster.ca
Wed Nov 20 19:00:35 UTC 2019
Ah, that looks perfect, thank you. Jacques
On 2019-11-20 1:15 p.m., Oleg Grenrus wrote:
> You need something like Lens to "zoom" into the state. As state monad
> can not only `get` but also `put` the state, the plain a -> b function
> is not enough: you need Lens a b.
> - Oleg
> On 20.11.2019 20.08, Jacques Carette wrote:
>> 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.
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> Only members subscribed via the mailman list are allowed to post.
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe