These are chat archives for dry-rb/chat

10th
Jul 2017
Brendon Murphy
@bemurphy
Jul 10 2017 04:03
Just checking to make sure I've got this straight: dry-transaction expects every service it calls to have a call method with arity 1. So if I wanted to say, pass along a user and a password from say, a CreateUser step...
Tim Riley
@timriley
Jul 10 2017 04:05
@bemurphy yes, right now we expect arity of 1 (turns out doing otherwise gets tricky)
so you could pass those two things as keyword args/hash
or make your own object that encapsulates the two, if it’s something you pass around a lot
Brendon Murphy
@bemurphy
Jul 10 2017 04:05
# Go
Dry::Monads::Right(user: user, password: password)
# No go
Dry::Monads::Right(user, password)
Tim Riley
@timriley
Jul 10 2017 04:05
Yep, that’s right
Brendon Murphy
@bemurphy
Jul 10 2017 04:05
@timriley cool, thanks
Tim Riley
@timriley
Jul 10 2017 04:06
We played with splatting arrays returned from operations into separate args for the next step
but the problem there is: what if you actually want to return a single real array?
Brendon Murphy
@bemurphy
Jul 10 2017 04:06
ah yeah, good point
Tim Riley
@timriley
Jul 10 2017 04:06
I think we’d need to add another concept to dry-transaction to support variable args from step-to-step
some kind of result object
Brendon Murphy
@bemurphy
Jul 10 2017 04:08
This is pretty edge anyhow, apparently I went to experiment first with the flow that's irritated me since 2006 (setting a temporary password, with a value not available to another instance)
in general, I can't imagine hitting a case where I couldn't just pass an instance down the pipe
Tim Riley
@timriley
Jul 10 2017 04:10
Yeah. I feel, in a way, this limitation is a good thing - it might encourage people to make a real value object to encapsulate commonly passed bundles of data
Brendon Murphy
@bemurphy
Jul 10 2017 04:11
for sure. I got it working with a hash, but then a few places I consume it, I'm calling #fetch out of paranoia. Seems like a payload object is warranted.
Brendon Murphy
@bemurphy
Jul 10 2017 04:17
Yup, that works, took all of about 4 lines. Thanks for the idea.
Tim Riley
@timriley
Jul 10 2017 04:17
Awesome!
Piotr Solnica
@solnic
Jul 10 2017 08:01
we should make monads accept a single arg
people will be tripping on this
Tim Riley
@timriley
Jul 10 2017 08:22
@solnic as in, leave it just like it is now?
Piotr Solnica
@solnic
Jul 10 2017 08:22
no, stop accepting Right(foo, bar)
so *args => arg
Tim Riley
@timriley
Jul 10 2017 08:26
@solnic we don't accept right(foo, bar) already
Nikita Shilnikov
@flash-gordon
Jul 10 2017 08:26
mb I'm missing something but it always worked like that
[1] pry(main)> Dry::Monads::Right(1, 2)
ArgumentError: wrong number of arguments (given 2, expected 1)
Piotr Solnica
@solnic
Jul 10 2017 08:26
so I'm confused
ignore me
Tim Riley
@timriley
Jul 10 2017 08:39
Haha
@solnic so what you're saying is that the current arrangement is something you're happy with? :)
Piotr Solnica
@solnic
Jul 10 2017 10:12
yes I am, I thought that Brendon tried both approaches, they both "worked" from method sig pov, and that got me confused
Tim Riley
@timriley
Jul 10 2017 10:39
Right :)
One thing dry-transaction could offer is an (opt-in) “context object” that is used to pass packets of data from operation to operation. But I worry that could lead to people passing too much around.
Piotr Solnica
@solnic
Jul 10 2017 12:44
yeah some kind of a conventional usage would be good