These combinators are like raiseUnder, but place the new effect at the
second and third position in the list.
This is for interpreters that consume two effects, delegating to two other interpreters...
@Torsten Schmits Cool, thanks!
While talking about "shuffling" effects around, what about porting lift from eff, which would allow us to reorder and add effects freely?
Well this is rather unfortunate! raise2Under actually means "raise an effect under two effects", and the existing raiseUnder2 actually means "raise two effects under the current one" :sweat_smile:
--------------------------------------------------------------------------------- | Raises effect stack by arbitrary number of effects.raise'::Raiserr'=>Semra->Semr'araise'=hoistSem$hoistraise'.raiseUnionraise::Semra->Sem(e':r)araise=raise'raiseUnder::Sem(e1':r)a->Sem(e1':(e2':r))araiseUnder=subsume'raiseUnder2::Sem(e1':r)a->Sem(e1':(e2':(e3':r)))araiseUnder2=subsume'raiseUnder3::Sem(e1':r)a->Sem(e1':(e2':(e3':(e4':r))))araiseUnder3=subsume'classRaise(r::[Effect])(r'::[Effect])whereraiseUnion::Unionrma->Unionr'mainstance{-# overlapping #-}RaiserrwhereraiseUnion=idinstance(r'~(_0:r''),Raiserr'')=>Raiserr'whereraiseUnion=(\(Unionnw)->Union(Theren)w).raiseUnion--------------------------------------------------------------------------------- | Allows reordering and adding known effects on top of effect stack, as long-- as polymorphic tail of new stack is 'raise'-d version of the original one.subsume'::Subsumerr'=>Semra->Semr'asubsume'=hoistSem$hoistsubsume'.subsumeUnionsubsume::Memberer=>Sem(e':r)a->Semrasubsume=subsume'classSubsume(r::[Effect])(r'::[Effect])wheresubsumeUnion::Unionrma->Unionr'mainstance{-# incoherent #-}Raiserr'=>Subsumerr'wheresubsumeUnion=raiseUnioninstance(Memberer',Subsumerr')=>Subsume(e:r)r'wheresubsumeUnion=eithersubsumeUnioninjWeaving.decompinstanceSubsume'[]rwheresubsumeUnion=absurdU
where names could be switched to raise and raiseN (for N in [1..3]) in v2
What's the right way to do this:
It seems that I would need to introduce an effect two levels deep, but I don't see a combinator for that. Is there a better way?
to be clear, I want
e3
not to be needed in the outside interpreter stackwhich works fine when
interp1
is a single effect, withraiseUnderN
I guess we should try to get
at some point
(from
eff
)yeah
for your FYI, I made combinators for this problem: https://github.com/polysemy-research/polysemy/pull/369
@TheMatten pls2check!
@Torsten Schmits Cool, thanks!
While talking about "shuffling" effects around, what about porting
lift
fromeff
, which would allow us to reorder and add effects freely?would love to! you wanna merge this anyway for the time being?
ah, I see you already approved. :rocket:
Even if we added
lift
later, we probably want these as more "inferable" variants, because they should produce much more sane type errorsWe would just turn them into call to
lift
in that caseright!
Well this is rather unfortunate!
raise2Under
actually means "raise an effect under two effects", and the existingraiseUnder2
actually means "raise two effects under the current one" :sweat_smile:again with the self-recursive calls where it's entirely non-obvious to me how this is terminating at all -_- (wrt
raiseUnder
)That recursive use should mostly matter in higher-order effects, where you call it on your argument to actually conform to "latest" row
So it stops at some point, because you don't have infinitely nested higher-order calls :slight_smile:
seems easy enough!
A little bit of incoherence and it can work with both concrete stacks and "polymorphic tails"
Should I open a PR? Or do you have some ideas for names? (those operators in
eff
are nice)(Haha, I wonder how many people used https://hackage.haskell.org/package/polysemy-zoo-0.7.0.0/docs/Polysemy-Operators.html :big_smile: )
Maybe something like
where names could be switched to
raise
andraiseN
(forN
in[1..3]
) in v2TheMatten said:
ooh, never seen those. not sure I find them very readable though, but I'd have to use them a bit to get an impression
I say make a PR and wait for comments over there
https://github.com/polysemy-research/polysemy/pull/370/