Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 05:53
    technofreak starred dry-rb/dry-monads
  • 00:14
    thekuwayama starred dry-rb/dry-monads
  • Dec 11 09:29
    blasterun starred dry-rb/dry-monads
  • Dec 11 08:34
    flash-gordon closed #115
  • Dec 11 08:34
    flash-gordon commented #115
  • Dec 11 08:31

    flash-gordon on v1.3.3

    (compare)

  • Dec 11 08:30

    flash-gordon on master

    Bump version to 1.3.3 (compare)

  • Dec 11 08:30

    flash-gordon on master

    Update CHANGELOG (compare)

  • Dec 10 23:46
    johnmaxwell commented #116
  • Dec 10 21:54

    flash-gordon on master

    Halt with mutable backtrace Ex… Merge pull request #116 from jo… (compare)

  • Dec 10 21:54
    flash-gordon closed #116
  • Dec 10 21:54
    flash-gordon commented #116
  • Dec 10 21:49
    johnmaxwell commented #116
  • Dec 10 21:47
    johnmaxwell commented #116
  • Dec 10 21:43
    johnmaxwell commented #116
  • Dec 10 21:39
    johnmaxwell commented #116
  • Dec 10 21:31
    johnmaxwell commented #116
  • Dec 10 21:22
    flash-gordon commented #116
  • Dec 10 19:41
    johnmaxwell opened #116
  • Dec 10 19:36
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic investigation yielded (like so often): own dumbness, I used ! (not), ... which is wrong :D
Michał Gutowski
@CucumisSativus

Hey guys i'm pretty fresh to dry monads and i've got a question about fmap. Lets suppose i've got code like this:

      validate.fmap do |valid_attributes|
        form.save.fmap do |valid_postcard|
          mailer.send_postcard(to_email: email, postcard: valid_postcard).deliver_now
          valid_postcard
        end
      end

both validate and form.save returns Left or Right. Is there a way to chain both those functions so they return Left or Right at the end of the chain? Now, when form.save returns Left at the end of the day I have Right(Left(errors)).
Am I doing something wrong? Is there a way to make it chainable?

Nikita Shilnikov
@flash-gordon
@CucumisSativus value combining will be probably added in future, but right now you can just do validate.bind instead of validate.fmap, this will give the result you want
Michał Gutowski
@CucumisSativus
@flash-gordon yeah that's exactly what i was looking for. Thanks a lot!
Nikita Shilnikov
@flash-gordon
np :)
Michał Gutowski
@CucumisSativus
@flash-gordon would you mind if I put your name (site?) in special thanks in my blogpost?
Nikita Shilnikov
@flash-gordon
@CucumisSativus I would not :) I don't have a site, you can add a gh link or twitter if you wish https://twitter.com/NikitaShilnikov
oh, well, that preview again
Michał Gutowski
@CucumisSativus
i'll let you know once I publish it :)
Jānis Miezītis
@janjiss
Hey folks, how would one deep copy Dry Container instance? :)
I want inherited object to have container with same values:
    def inherited(subclass)
      subclass.instance_variable_set(:"@container", Marshal.load(Marshal.dump(_container)))
    end
It works this way, just woundering if there is a better way to do it
Jānis Miezītis
@janjiss
Well, I think this is better:
    def inherited(subclass)
      subclass_container = Dry::Container.new
      _container.each_key do |k|
        subclass_container.register(k, _container.resolve(k).clone)
      end
      subclass.instance_variable_set(:"@container", subclass_container)
    end
Don Morrison
@elskwid
@janjiss my experience with Marshal.load and Marhsal.dump has led me to this wisdom: don’t use them. I’ve seen the formats change on Ruby point releases. Not fun. That second one is better even if just for the ability to withstand an upgrade. :smile:
Jānis Miezītis
@janjiss
@elskwid Yeah, I can se how that can become a problem
Piotr Solnica
@solnic
Yes. I wouldn't rely on marshaling
Mikhail Slyusarev
@mikhailvs
do you guys actually use dry-rb in production?
John Backus
@backus
We do
dry-validation and dry-types
works great
Mikhail Slyusarev
@mikhailvs
hmm... i've refactored a pretty big app to use dry-containers/validation/transactions but i'm feeling a bit reluctant to pull the trigger on deploying it
either way. it seems like a very cool collection of libraries
John Backus
@backus
If you have good tests I think you should be safe although I can't vouch for containers and transactions
just lock yourself to a strict version
Mikhail Slyusarev
@mikhailvs
yeah... for sure
Piotr Solnica
@solnic
@mikhailvs what’s your concern?
Mikhail Slyusarev
@mikhailvs
Honestly, I've only very recently stumbled upon dry-rb, and it's hard to gauge how widely it's being used. I suppose it's not a real concern though, more like curiousity.
Piotr Solnica
@solnic
@mikhailvs it’s used on production by many people
it is unstable though, so APIs may change from time to time until we hit 1.0.0
Mikhail Slyusarev
@mikhailvs
Is there a way to set a message for a custom dry-validation predicate without loading a yaml file?
Piotr Solnica
@solnic
not yet
I mean…it is possible to merge in your own messages
Mikhail Slyusarev
@mikhailvs
is that not recommended/
what you linked to actually seems like a pretty sane way of doing that
Piotr Solnica
@solnic
well, I don’t like it but it doesn’t mean it’s not recommended. personally I dislike having core objects of my system cluttered with UI-related configurations
Mikhail Slyusarev
@mikhailvs
I can see that. I'd still feel like there's UI stuff polluting backend code with a yaml conf file though... especially with api driven apps.
Piotr Solnica
@solnic
how come? that’s a nice separation, just like you separate html templates from objects that provide data for rendering, it’s somewhat similar here
Mikhail Slyusarev
@mikhailvs
I mean it's stuff that shows up on the frontend, being defined in files of the backend project.
Piotr Solnica
@solnic
you could render them on the client side and have message templates defined there
Mikhail Slyusarev
@mikhailvs
I'm not saying I have a different/better approach though. But it seems like the kind of error something is, is coupled with the text description of it, and since the error is generated on the backend, it's fine for other components of it to be defined there as well.
yeah, that's what I'd do if I felt super strongly about it
Piotr Solnica
@solnic
it’s actually not coupled, we translate generic result object into whatever we want, but since generating string messages is what most people need, it’s been baked into the library
I just made it work with plain YAML because some times you may want to skip i18n as a dependency
Mikhail Slyusarev
@mikhailvs
Well when you create a custom predicate for a schema it seems like there's at least a logical coupling of its definition and the error message it could generate
Piotr Solnica
@solnic
you can still apply that predicate w/o generating a message
messages are generated only when you ask for them
Mikhail Slyusarev
@mikhailvs
as in, when you call .messages?
Piotr Solnica
@solnic
right, or in 0.10.0 errors
Mikhail Slyusarev
@mikhailvs
that makes sense