These are chat archives for dry-rb/chat

30th
Aug 2016
RKushnir
@RKushnir
Aug 30 2016 08:27
Hi. How would I go about validating a form with a date range, so start date must be before the end date?
Piotr Solnica
@solnic
Aug 30 2016 10:30
@RKushnir rule(date: %i[start_date end_date]) { |s, e| s.lt?(e) }
RKushnir
@RKushnir
Aug 30 2016 10:31
@solnic can I customize the format in which I receive the date?
I guess, I would need to look at dry-types to implement a “custom-date” thing, right?
Piotr Solnica
@solnic
Aug 30 2016 10:34
@RKushnir what format is it?
if it’s not anything bizzare we may just add it to dry-types
RKushnir
@RKushnir
Aug 30 2016 10:35
@solnic and if it’s actually bizarre? :)
Piotr Solnica
@solnic
Aug 30 2016 10:36
haha :) you can use a custom type then :)
@RKushnir MyDate = Types::Strict::Date.constructor { |v| … }
just remember in that block you need to handle errors yourself
RKushnir
@RKushnir
Aug 30 2016 10:38
@solnic ok, thank you, I’ll play with it
Piotr Solnica
@solnic
Aug 30 2016 10:38
you can also normalize input so it’s parsable by the built-in date
RKushnir
@RKushnir
Aug 30 2016 10:39
oh, can I do it with the dry-v?
or do you mean before I pass it to validation?
Piotr Solnica
@solnic
Aug 30 2016 10:41
irb(main):014:0> MyDate = Types::Strict::Date.constructor { |v| Types::Form::Date[v.values_at(:year, :month, :day).join(‘/')] }
=> #<Dry::Types::Constructor …
irb(main):015:0> MyDate[year: 2016, month: 8, day: 30]
=> #<Date: 2016-08-30 ((2457631j,0s,0n),+0s,2299161j)>
Feel free to do things like that
RKushnir
@RKushnir
Aug 30 2016 10:44
I see, thanks, will spend a day trying how dry-v fits in our project in place of AM:validations
Sergey Novikov
@droptheplot
Aug 30 2016 12:08
Hi everyone!
I have a question about dry-types. Using constructor_type(:schema) and .optional method I could skip an attribute but it will be initialized anyway only with nil value. Is it possible to make attribute really optional?
Kiril Dokh
@dsounded
Aug 30 2016 13:26
@solnic Hello, is there anything like scala’s .getOrElse for Maybe monad ?
Oh, .or, I see
Piotr Solnica
@solnic
Aug 30 2016 13:29
@dsounded best to talk to @flash-gordon as I literally didn’t touch dry-monads at all :)
Kiril Dokh
@dsounded
Aug 30 2016 13:30
@solnic I’ve found it, but monads are absolutely awesome stuff, haven’t you guys thought about ID monad ?
Piotr Solnica
@solnic
Aug 30 2016 13:31
@dsounded no idea :) as I mentioned, I didn’t participate in the development of this gem (yet) but I’m totally interested in it
I use it through dry-transactions so it’s very limited usage from my pov
I think Scala could be a great source of inspiration btw
Kiril Dokh
@dsounded
Aug 30 2016 13:32
Yeah, because there are a lot of functional stuff in Ruby, more than Java has or other OO languages
Piotr Solnica
@solnic
Aug 30 2016 13:33
pretty much yeah
I’m pretty sure a lot can be done that’s similar to Scala
Kiril Dokh
@dsounded
Aug 30 2016 13:47

@solnic this is a way to go :)

https://github.com/typelevel/cats

Piotr Solnica
@solnic
Aug 30 2016 13:52
@dsounded oh cool, didn’t know this one, i’ll check it out
thanks for sharing
Kiril Dokh
@dsounded
Aug 30 2016 13:52
it’s haskell way for scala, for me it’s much more cool than scalaz
Piotr Solnica
@solnic
Aug 30 2016 13:56
it’s interesting to see that people are bringing haskellish APIs to other langs, there are libs like that for Clojure too
Kiril Dokh
@dsounded
Aug 30 2016 14:00
Because I do believe everyone doesn’t want to write stuff as if a.nil?… :)
Michał Warda
@michalwarda
Aug 30 2016 14:17
Hi guys I gotta make a schema where inside a nested schema I got an array of items which should all fulfill a schema: required(:output).schema { required(:cities).each(+here put a schema somehow+) } and I can't seem to get it working
Piotr Solnica
@solnic
Aug 30 2016 14:19
@michalwarda required(:cities).each { schema(YourSchema) }
Michał Warda
@michalwarda
Aug 30 2016 14:26
@solnic Thank's a LOT! :+1:
Hannes Maack
@rocknruby
Aug 30 2016 14:27
Hi @dsounded, you reacted with :thumbsdown: for my PR - dry-rb/dry-monads#20 ? Would like to know the reason, am I missing sth?
Hannes Maack
@rocknruby
Aug 30 2016 14:44
Closed it after a check by my self. I’ll open again it again if its ready to read. :worried:
Nikita Shilnikov
@flash-gordon
Aug 30 2016 17:24
@dsounded we implemented few monads by more or less copying them from kleisli gem
the main reason was lack of maintenance
I was surprised to found myself a maintainer of monads gem
I'm a pl/sql developer, at least sort of
so I started to learn haskell
now I'am at page 900 and there is still no comprehensive monads description :)
As well as a series of posts of Bartosz Milewsky about th.categories
Nikita Shilnikov
@flash-gordon
Aug 30 2016 17:39
@nepalez thx, I'll check it out too, when I'm done with that book :)
John Backus
@backus
Aug 30 2016 22:35
@solnic I rebased and pushed my other two open PRs on dry-types now that you've merged dry-rb/dry-types#133
Piotr Solnica
@solnic
Aug 30 2016 22:36
@backus great
John Backus
@backus
Aug 30 2016 22:36
One depends on @flash-gordon's PR but the other is small
This is the mergeable one: dry-rb/dry-types#134
dry-rb/dry-types#135 includes improved test coverage for all the schemas including the schema dry-rb/dry-types#134 adds
John Backus
@backus
Aug 30 2016 23:01
@solnic change it to raise all unexpected keys
John Backus
@backus
Aug 30 2016 23:06
:tada:
Piotr Solnica
@solnic
Aug 30 2016 23:06
:)
John Backus
@backus
Aug 30 2016 23:07
@solnic regarding "Looks like there are conflicts with master" I'm rebasing now
If you could tackle dry-rb/dry-types#137
I'll have the other PR ready for you
@solnic rebase of dry-rb/dry-types#137 is done
Oop and you merged
Piotr Solnica
@solnic
Aug 30 2016 23:10
wait
what did I do? :D
John Backus
@backus
Aug 30 2016 23:10
No you're fine
Piotr Solnica
@solnic
Aug 30 2016 23:10
ok
John Backus
@backus
Aug 30 2016 23:10
As soon as I rebased on master you merged dry-rb/dry-types#137 which I wanted
Piotr Solnica
@solnic
Aug 30 2016 23:10
sorry, brain half-fried (past 1am here)
John Backus
@backus
Aug 30 2016 23:11
so I just had to rebase again
It is rebased on top of the latest master again now
Don't know if you care about this too but all of the commits individually pass too
Piotr Solnica
@solnic
Aug 30 2016 23:11
I do
John Backus
@backus
Aug 30 2016 23:11
kk
Piotr Solnica
@solnic
Aug 30 2016 23:11
I try to work like as well
John Backus
@backus
Aug 30 2016 23:11
It is impossible to demonstrate that with travis as the CI
but I always do git rebase origin/master -x 'bundle exec rspec'
Piotr Solnica
@solnic
Aug 30 2016 23:14
that’s a nice trick
Tim Riley
@timriley
Aug 30 2016 23:15
TIL!
John Backus
@backus
Aug 30 2016 23:16
Super satisfying with this PR too :P
Each rspec run ends with a higher "X examples, 0 failures"
John Backus
@backus
Aug 30 2016 23:26
:skull: <-- me waiting for jruby-head to finish on CI
Alright dry-rb/dry-types#135 is green @solnic
Piotr Solnica
@solnic
Aug 30 2016 23:32
@backus I’d vote for removing jruby-head from all builds
it’s been killing me too
@nepalez I’m evaluating dry-initializer as a replacement for ROM::Support::Options it seems like it’s a bit slower but if we could make it equally fast I’d ditch ROM::Support::Options right away
Piotr Solnica
@solnic
Aug 30 2016 23:41
oh interesting, without type checking it’s much faster, which actually is not a surprise given the overhead dry-t’s constraints add
I guess this will go away soon though, as I’m working on huge perf improvements in the rule engine (dry-logic)
the bottleneck is that we create result objects even for succesfuly applied rules, by default, this will be opt-in behavior in the next version and it’ll speed things up multiple times
so I guess I should be able to use dry-initializer in rom, is what I wanted to say :)
John Backus
@backus
Aug 30 2016 23:46
This was satisfying
got a whole weekend of commits merged in :)
Piotr Solnica
@solnic
Aug 30 2016 23:55
@backus #progress :D