Zulip Chat Archive

Stream: lean4

Topic: monadic pipe projection


Scott Morrison (Mar 10 2023 at 03:30):

Is there a monadic version of the pipe projection |>.?

e.g. if I have f : MetaM Expr, I might find myself writing pure (← f).headBeta, but would love to write e.g. f $>.headBeta.

James Gallicchio (Mar 10 2023 at 03:57):

I've also been wanting something along those lines. It would make some functional-but-with-effects code way more readable

James Gallicchio (Mar 10 2023 at 03:58):

Let's make a metaphor to C, and have |>-> as the "dereferencing" version of |>. :) [joke]

Mario Carneiro (Mar 10 2023 at 05:04):

you can do (·.headBeta) <$> f

Mario Carneiro (Mar 10 2023 at 05:04):

or f <&> (·.headBeta) if you like the argument order


Last updated: Dec 20 2023 at 11:08 UTC