These are chat archives for dry-rb/chat

8th
Sep 2016
John Backus
@backus
Sep 08 2016 09:51
@solnic looks like I'll have time to wrap up dry-types / dry-struct things tomorrow :)
Piotr Solnica
@solnic
Sep 08 2016 09:51
@backus oh that would be amazing
it’s possible I’ll wrap up dry-v too…
we’d have an EPIC release then
John Backus
@backus
Sep 08 2016 09:51
I don't know if I'll be able to finish it all but I'll have a solid 6-8 hours
and I can prioritize properly to get the necessary functionality ready and then dive into refactoring
to make it most likely we have something releaseable
I just don't want the schemas in dry-t to have so much duplication :'(
Piotr Solnica
@solnic
Sep 08 2016 10:01
this is the tricky part
I optimized for performance hence duplication but who knows, maybe it can be cleaner & faster somehow :)
John Backus
@backus
Sep 08 2016 10:02
Yeah I'll try to be conscious of that
The other aspect I'm unsure about is whether constraints should ideally be represented in dry logic as much as possible
or if we would rather do all of this key checking, default value filling, and coercion directly like it currently does
Piotr Solnica
@solnic
Sep 08 2016 10:04
dry-logic is now few times faster so we could consider that
and there are opportunities for more optimization there
John Backus
@backus
Sep 08 2016 10:05
Cool
I also imagine that, for dry-v and dry-t, the more that can be expressed using dry logic the better (barring big perf hits)
Piotr Solnica
@solnic
Sep 08 2016 10:06
yeah I mean that was my intention when I extracted dry-logic (it was part of dry-validation originally)
John Backus
@backus
Sep 08 2016 10:06
Right
Piotr Solnica
@solnic
Sep 08 2016 11:48

ok folks I’m done with logic/validation stuff…I’d appreciate if you could add this:

gem 'dry-validation', github: 'dry-rb/dry-validation', branch: 'master'
gem 'dry-types', github: 'dry-rb/dry-types', branch: 'master'
gem 'dry-struct', github: 'dry-rb/dry-struct', branch: 'master'
gem ‘dry-logic’, github: 'dry-rb/dry-logic', branch: 'master'

to your Gemfile and run your tests…

Nikita Shilnikov
@flash-gordon
Sep 08 2016 11:53
@solnic dry-rb/dry-validation#238 <- I'll update this today
Piotr Solnica
@solnic
Sep 08 2016 12:04
@flash-gordon cool, you could collaborate with @cored as he’s working on optional dry-struct support which has the identical problem as it needs feature detection too
@fran-worley hey! could you tell me if latest stuff from master works fine with Reform and friends?
Rafael George
@cored
Sep 08 2016 12:24
@flash-gordon hey
@solnic according to that issue the dependency then should be remove from the Gemfile? I mean by optional you mean that the user will install the dependency by itself ?
s/itself/himself
Nikita Shilnikov
@flash-gordon
Sep 08 2016 12:27
@cored hey, that's what @solnic told me: https://github.com/dry-rb/dry-validation/pull/238#issuecomment-244924977 :) I'm just gonna do a monkey-patch with opt-in to_either method
so this case is trivial ^
Rafael George
@cored
Sep 08 2016 12:28
so you will try to require at the same method level ?
Nikita Shilnikov
@flash-gordon
Sep 08 2016 12:30
@cored require 'dry/monads/either'; require dry-v/either-ext at the end of result.rb I think, with LoadError being caught
Rafael George
@cored
Sep 08 2016 12:32
I see
Nikita Shilnikov
@flash-gordon
Sep 08 2016 12:40
@cored dry-struct part can be done with a runtime check like defined? ::Dry::Struct && input < ::Dry::Struct
Rafael George
@cored
Sep 08 2016 12:40
I see
so since some specs have a definition for an struct, I guess the check also will be there
Piotr Solnica
@solnic
Sep 08 2016 12:48
meh, seems like OR-handling still needs some work
Fran Worley
@fran-worley
Sep 08 2016 13:45
@solnic I'll check today and get back to you. We will hold off our next release until dry-validation 0.10.0 is out as I want to use some of the goodies you've added :)
Piotr Solnica
@solnic
Sep 08 2016 13:50
@fran-worley this has to wait until next week, I thought I’d make it before end of this week but I failed
Fran Worley
@fran-worley
Sep 08 2016 13:52
Oh no worries, @apotonick is busy at the moment so we won't be releasing any earlier. When we do release it will be a big dry-v plug as the update is essentially improving Reforms integration with dry
Piotr Solnica
@solnic
Sep 08 2016 13:53
that’s great, I’ll try to help
Fran Worley
@fran-worley
Sep 08 2016 13:55
Definitely more trailblazer people are switching over especially as @apotonick has set it up so you can gradually transition an app from AM-V to dry.
Russell Edens
@rx
Sep 08 2016 17:19
@solnic, @backus backing up to your conversation earlier today ... In working on dry-rb/dry-validation#67 I wanted to provide a consistent api for discovering fields in a dry-v and a dry-s. Having both libraries use a more consistent schema interface would make this much cleaner. As it is right now I have to make dry-l look more like dry-v at the rule-ast level.
I'll be pushing some code to look at later today/tonight.
^^ unfortunate typo - should be: As it is right now I have to make dry-s look more like dry-v at the rule-ast level.
Piotr Solnica
@solnic
Sep 08 2016 18:00
@rx did you use dry-logic from master? it changed quite a bit
Russell Edens
@rx
Sep 08 2016 20:21
@solnic I have been following the changes. I'm re-working the work I did against master now.
Piotr Solnica
@solnic
Sep 08 2016 20:32
@rx I’m not entirely sure if it’s the best direction but we’ll see. rules are not for defining data structures, they are generic. We can easily add generating some meta-data in dry-v schemas though, or try to use generated dry-t’s schemas (that do define the structures). I think I mentioned that in the related issue :)
Russell Edens
@rx
Sep 08 2016 21:07
@solnic yes I started down that route but it started feeling like I was pushing the metadata requirements into both dry-v and dry-s, when the rules_ast already had everything that is needed (and more). This lead me to treating the metadata api more like an extension, like you mentioned earlier in the issue :smile: I translated dry-s rules-ast to dry-v rules-ast temporarily to allow me to start using the extension with dry-s. The next step is resolving the non-symmetrical dry-s and dry-v schemas, that would allow me to throw away my temporary dry-s(ast)->dry-v(ast) translation. This approach allowed me to build a more complete set of metadata for both dry-v and dry-s with minimal dependencies and saving anyone else from groking the underlying rules_ast. :smile: If the underlying rules_ast is likely to change more than the dry-s and dry-v object model then I did indeed take a wrong turn.
Russell Edens
@rx
Sep 08 2016 21:13
@solnic I just happened to embark on this approach, then I saw you refactored the dry-l ast. :worried:
Piotr Solnica
@solnic
Sep 08 2016 21:15
sorry about that, it’s been planned for months, I actually didn’t know you started working on this
fwiw the ast approach is going to be the most powerful, so assuming it’s easy to translate it to what we need, this will be the best approach :)
Russell Edens
@rx
Sep 08 2016 21:21
No problem. it should be very easy to re-map. I'll provide a heads up next time. I was just trying to stay out of the way. It looked like you got some really good stuff done.
Right now I'm putting this into its own repo as a WIP for you to look at.
Piotr Solnica
@solnic
Sep 08 2016 21:27
yes these are major improvements bringing us much closer to 1.0.0’s
Russell Edens
@rx
Sep 08 2016 21:27
:clap:
Piotr Solnica
@solnic
Sep 08 2016 21:27
I still need to improve OR-message handling though (it’s a tricky beast…)
Russell Edens
@rx
Sep 08 2016 21:28
yes it would be by definition!
btw - I had trouble finding a dry-v rules_ast set and not examples. Do you have one? And do you want me to open an issue or PR against the website documentation?
Piotr Solnica
@solnic
Sep 08 2016 21:35
@rx are you asking about examples of DSL usage in dry-v?
Russell Edens
@rx
Sep 08 2016 21:45
@solnic yes.
I built my specs using the documentation on the website.
Piotr Solnica
@solnic
Sep 08 2016 21:46
I barely covered 50% of the functionality in the docs :)
(not sure why I’m smiling lol)
required(:admin) { true? | true?.not } == required(:admin) { true? | false? }
we could probably add support for not(true?) though
it’d look better
Russell Edens
@rx
Sep 08 2016 21:48
Yes I know, I dug around the specs/code to find the rest. I also found missing predicates from #155.
:+1: on not(true?)
Would you like issues opened on the website for missing doc items?
thx!
Piotr Solnica
@solnic
Sep 08 2016 21:53
@rx yes website’s issue tracker is the right place
Russell Edens
@rx
Sep 08 2016 21:53
I know you'd like PR's for the missing doc items! :worried:
@solnic will do
@solnic do you have an example of a dry-v 'set' off the top of your head?
Piotr Solnica
@solnic
Sep 08 2016 21:57
@rx every time you define more than one key you end up with a set rule
it’s basically a list of rules that must be applied to the same input
Russell Edens
@rx
Sep 08 2016 21:57
ok - so they don't really show up in the rules_ast
Piotr Solnica
@solnic
Sep 08 2016 21:57
they do
Russell Edens
@rx
Sep 08 2016 21:59
alright, looks like I'm missing a spec
Piotr Solnica
@solnic
Sep 08 2016 22:01
oh actually we don’t create :set from multiple keys
it’s just an array of individual rules that will be executed
Russell Edens
@rx
Sep 08 2016 22:04
@solnic so is there a dry-v schema that will generate a :set rule_ast? (I'm throwing not implemented, so I haven't found it yet.)
Piotr Solnica
@solnic
Sep 08 2016 22:07
@rx just ignore it for now
Russell Edens
@rx
Sep 08 2016 22:07
ha didn't escape that one
@solnic will do
@solnic thanks for your help!
Wilson Silva
@wilsonsilva
Sep 08 2016 22:44
I'm getting a privacy error on Chrome when I try to access https://discuss.dry-rb.org/
Piotr Solnica
@solnic
Sep 08 2016 22:58
@wilsonsilva uhm, lemme see
@wilsonsilva green for me
safari ff and chrome