You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...but using >> requires the util method to accept an additional parameter, making things less composable.
I have an idea for making Deterministic more streamline. If you're willing to make a breaking change, I think it might be better to use the three operators >=, >, and <. Although it's not nearly as cool as using >>, the advantage is they all have the same precedence.
Here is what I think each one should do:
>= is haskell's >>=
> is haskell's >>
< is Deterministic's pipe
Note that try is no longer an operator. I think this is ok because, thanks to functional programming, we can easily abstract it into its own method:
require'deterministic'classAttemptExampleincludeDeterministicdefattempt(method_name)lambdado |ctx|
beginself.send(method_name,ctx)rescueException=>eFailure(e)endendenddefrun(input)# Equivalent to the current do_something(input) >= method(:fail)do_something(input) >> attempt(:fail)enddefdo_something(input)Success(input)enddeffail(input)raise"BOOM"endenda=AttemptExample.newputs"RESULT: #{a.run(true).inspect}"
What do you think? I think this will make Deterministic a great joy to use! I am also open for discussion.
The text was updated successfully, but these errors were encountered:
I'm trying to use the equivalent of
>>
in haskell, which discards the result of the previous call:...but using
>>
requires theutil
method to accept an additional parameter, making things less composable.I have an idea for making Deterministic more streamline. If you're willing to make a breaking change, I think it might be better to use the three operators
>=
,>
, and<
. Although it's not nearly as cool as using>>
, the advantage is they all have the same precedence.Here is what I think each one should do:
>=
is haskell's>>=
>
is haskell's>>
<
is Deterministic'spipe
Note that
try
is no longer an operator. I think this is ok because, thanks to functional programming, we can easily abstract it into its own method:What do you think? I think this will make Deterministic a great joy to use! I am also open for discussion.
The text was updated successfully, but these errors were encountered: