I'm trying to migrate my code from Control.Monad.Free to polysemy; does anyone have an example that shows how to use the State effect in my own effect?
dataActivityLangmawhereSetNote'::Text->ActivityLangm()makeSem''ActivityLangrunActivityPure::Sem(ActivityLang': r) a -> Sem r arunActivityPure=interpret$\caseSetNote's->pure()-- TODO: modify the reader env using `s`runFoo::Sem(ActivityLang:State(Entry'CoveredMaybe):r)a->Semr_runFoo=runStateinitialEntry.runActivityPure
But how would you compose the two effects so I can use the reader in SetNote'?
End goal: "ActivityLang" describes the DSL to ultimately build (piecemeal) a Haskell record . So it is pure, except for using a State to represent intermediate states of the record (represented using barbie HKD)
I'm trying to migrate my code from
Control.Monad.Free
to polysemy; does anyone have an example that shows how to use the State effect in my own effect?This compiles:
But how would you compose the two effects so I can use the reader in SetNote'?
(Correction: State, not Reader)
End goal: "ActivityLang" describes the DSL to ultimately build (piecemeal) a Haskell record . So it is pure, except for using a
State
to represent intermediate states of the record (represented using barbie HKD)@Sridhar Ratnakumar try
reinterpret
:That worked, and I've successfully migrated to polysemy!