Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 22 09:10
    Benoit-Baumann starred dry-rb/dry-monads
  • May 21 16:11
    kholdrex starred dry-rb/dry-monads
  • May 19 15:16
    cllns edited #255
  • May 19 07:00
    radar edited #440
  • May 19 05:51
    flash-gordon commented #440
  • May 18 23:22
    radar labeled #440
  • May 18 23:22
    radar labeled #440
  • May 18 23:22
    radar opened #440
  • May 17 14:06
    flash-gordon closed #96
  • May 17 14:06
    flash-gordon commented #96
  • May 17 12:08
    olkeene labeled #96
  • May 17 12:08
    olkeene labeled #96
  • May 17 12:08
    olkeene opened #96
  • May 13 10:11
    jonathanmdavies starred dry-rb/dry-monads
  • May 12 18:05
  • May 12 07:48
    Jordybastien starred dry-rb/dry-monads
  • May 11 21:14
    christoomey commented #124
  • May 11 12:03
    adam12 starred dry-rb/dry-types
  • May 10 22:35
    maxjustus starred dry-rb/dry-monads
  • May 10 13:21
Nikita Shilnikov
@flash-gordon
@pabloh wdym by saying "context"? A transaction just accepts arguments and returns a result, it doesn't have any mutable internal state
Pablo Herrero
@pabloh
Doesn't it keep a context along the way where you can grab values?
Is not possible to store partial results somewhere there to use on subsequent steps?
Nikita Shilnikov
@flash-gordon
you just pass them from one step to another
I use keyword args for passing several values at once
def my_step(value_1: , **rest)
  value_1_transformed = do_something(value_1)
  Right(value_1: value_1_transformed, **rest)
end
@pabloh like this^
Pablo Herrero
@pabloh
So you need to make your result value a hash?
Nikita Shilnikov
@flash-gordon
I use hashes, but it's up to you. You also can define a custom step http://dry-rb.org/gems/dry-transaction/custom-step-adapters/, but this is advanced usage :)
Pablo Herrero
@pabloh
My question is do you have to put a hash besides the actual value in the result to have some kind of context?
Nikita Shilnikov
@flash-gordon
can be arrays also, or you can define your own "context" object
the main point is that dry-transaction doesn't have a mutable state inside
Pablo Herrero
@pabloh
I understand that, I meant "change" the context in the same way the state monad updates its "state".
Nikita Shilnikov
@flash-gordon
yeah, in this sense a new type of step will be useful, atm we don't have any special "context" object
txn = define_transaction do
  custom_step_adapter 'step_1', using: :value_1
  custom_step_adapter 'step_2', using: :value_2
  map 'step_3'
end

txn.call(value_1: 1, value_2: 2)


def my_step(value_1)
  value_1 + 1
end

def my_step(value_2)
  value_2 + 1
end

def step_3(context)
  context # { value_1: 2, value_2: 3 } 
end
@pabloh for example^
Nick Sutterer
@apotonick
@pabloh That's basically and exactly what a TRB operation provides (sorry for high-jacking)
Pablo Herrero
@pabloh
Ok, will check it out.
Nick Sutterer
@apotonick
@pabloh There a "context" object, we call it options which is basically a hash, and passed from step to step (per default) http://trailblazer.to/gems/operation/2.0/#state-and-result
Pablo Herrero
@pabloh
So you just store the actual result in :model as a convention?
Pablo Herrero
@pabloh
@apotonick, any reason yoy prefered that approach instead of storing the result separately?
Nick Sutterer
@apotonick
@pabloh The result is stored separately! The options hash scopes, and knows who added what
However, most operations don't need that, so the "human" interface is very simple and looks "global", but it isn't. It took months to design it
Pablo Herrero
@pabloh
I see, I think I could take a dive in the code in order to fully get it after I check out the docs some more.
George Millo
@georgemillo
hey, when I clone the dry-types repo and run specs, I get failures for all tests that involve a maybe type
I imagine that this is something to do with dry-monads not being loaded?
how do I make the tests pass?
Nikita Shilnikov
@flash-gordon
@georgemillo run with rake
George Millo
@georgemillo
aha
thanks
looks like rake runs two rspec suites
what's going on there?
Nikita Shilnikov
@flash-gordon
with/without monads ext
George Millo
@georgemillo
oh wait, I answered my own question by looking in the Rakefile
funny how that happens
Piotr Solnica
@solnic
@flash-gordon I’d like to revisit hash schema implementation in dry-types, and try to figure out a more flexible way for setting them up. This was brought up before by @Kukunin I believe, I was initially against it, but we start to see more use cases where a more flexible solution would be very useful. /cc @backus
ie now we need a symbolized hash which has strict semantics too, and we’re stuck :)
this is definitely something to figure out before 1.0.0
if we can come up with a flexible solution which is also fast, that would be awesome. Oh and the lib should still provide a bunch of common, built-in hash schema types
@apotonick I’ll let you know once I have something working with the new dry-v + dry-schema, and re rom, I reported an issue about reform/rom integration so we can discuss things there I guess
Sergey Kukunin
@Kukunin
@flash-gordon I have a crash on latest master of dry-struct. on the first attribute call.
equalizer.instance_variable_get('@keys').concat(new_schema.keys)
NoMethodError: undefined method `concat' for nil:NilClass
  /Users/kukunin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/dry-struct-fbe71e6445a8/lib/dry/struct/class_interface.rb:78:in `attributes'
  /Users/kukunin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/dry-struct-fbe71e6445a8/lib/dry/struct/class_interface.rb:50:in `attribute'
  /Users/kukunin/Sites/matic-www/gems/shift-domain/lib/shift/domain/attachment.rb:8:in `block in <module:Domain>'
Nikita Shilnikov
@flash-gordon
@Kukunin I think you need dry-core from master, check it out
Sergey Kukunin
@Kukunin
thanks. going to try
yep. that's the reason. thanks
any plans to release dry-struct 0.2.2 with minor changes?
it seems that major changes are coming (already in master)
Nikita Shilnikov
@flash-gordon
nope, I'll release 0.3, soon. Bumping dry-core will require releasing rom as well, takes some time...
Sergey Kukunin
@Kukunin
what's about releasing dry-rb/dry-struct@bfc867e commit as 0.2.2?
and next release will be 0.3
Nikita Shilnikov
@flash-gordon
too late :) I don't have time for this