These are chat archives for dry-rb/chat

11th
Aug 2016
Tim Riley
@timriley
Aug 11 2016 01:12
looking at it again now
Jānis Miezītis
@janjiss
Aug 11 2016 02:21
Is there any way that I can get all relation keys that are defined with as: ?
Tim Riley
@timriley
Aug 11 2016 03:13
@janjiss is this a question for rom-rb/chat?
Darcy Laycock
@Sutto
Aug 11 2016 03:56
@solnic very delayed response :P We’re using Virtus as smarter structs (with cooercion etc) - so I worked out how to replace it with dry-types etc pretty well, just a matter of doing it now (which means time hah)
Tim Riley
@timriley
Aug 11 2016 03:57
:)
Darcy Laycock
@Sutto
Aug 11 2016 03:57
and to the second bit, we’re using http://json-schema.org/ - since most of our types happen at point of ingestion / passed around as JSON (not inside ruby, but heaps of different languages / tools)
now looking at basically taking a json schema and compiling it to a dry-validation / dry-types object, so I can do coercion
Tim Riley
@timriley
Aug 11 2016 03:58
That’d be a sweet tool, @Sutto!
I hope you can share it, if you do build it
Darcy Laycock
@Sutto
Aug 11 2016 03:59
will be open source :)
basically trying to solve a couple of problems: 1. We want a strict definition of types (for external people)
but also we want to be intelligent about coercion in our setup
e.g. drop null-only values for most keys, converting string numerics to numbers
but that happens prior to schema validation, ultimately
Tim Riley
@timriley
Aug 11 2016 04:01
Yep
Piotr Solnica
@solnic
Aug 11 2016 09:58
@Sutto no worries. So, you’re gonna apply coercions to input that is known to be already valid, right?
@timriley ping?
Piotr Solnica
@solnic
Aug 11 2016 10:10
@Sutto I should mention that I plan to build a new coercion lib with type-safety, it’s gonna be targetting cases where you coerce input that is potentially invalid in terms of types, maybe it’s the same thing that you need - if that’s the case, we could collaborate on it :)
we have bits and pieces in place like dry-types (for defining types with coercions) and dry-logic (which provides various predicates that can be useful)
Tim Riley
@timriley
Aug 11 2016 10:33
@solnic pong :metal:
Piotr Solnica
@solnic
Aug 11 2016 10:34
@timriley thanks for the review, I addressed all issues and it’s merged now. I also renamed the repo…
Tim Riley
@timriley
Aug 11 2016 10:34
@solnic excellent!
Piotr Solnica
@solnic
Aug 11 2016 10:37
@timriley it’s shaping up man…! :)
Darcy Laycock
@Sutto
Aug 11 2016 12:55
@solnic kind of - I want to the validations (in this case) not just to be literal (e.g. type checks) to be “can we make it match this schema” exactly
example being year - some sources we have it as numbers, some strings - we care it’s processed as a number and meets the number range requirements
the json-schema stuff is very literal
Piotr Solnica
@solnic
Aug 11 2016 13:03
@Sutto then it sounds exactly like what I want to build. We’re very close to have that with existing dry-v/t combo, but I feel like we could have some more dedicated. We may just extend dry-types though instead of building another lib, we’ll see
Kiril Dokh
@dsounded
Aug 11 2016 13:13
@solnic hello, mate, do you remember about me ?)
Piotr Solnica
@solnic
Aug 11 2016 13:18
I do. Will start working on dry-v again tomorrow /cc @fran-worley
Fran Worley
@fran-worley
Aug 11 2016 13:25
@solnic I'd best get my brain back to where it was when we left off :)
Piotr Solnica
@solnic
Aug 11 2016 13:26
I hear you
Jānis Miezītis
@janjiss
Aug 11 2016 14:06
@timriley I’m hoping to publish devise/rom gem. If this is not right place to ask, I am sorry :)
Andy Holland
@AMHOL
Aug 11 2016 15:14
@janjiss would be better in https://gitter.im/rom-rb/chat
Jānis Miezītis
@janjiss
Aug 11 2016 15:14
Thanks @AMHOL
Andy Holland
@AMHOL
Aug 11 2016 15:15
NP
Jānis Miezītis
@janjiss
Aug 11 2016 15:15
OH, lol, I didn’t notice that it is dry-* chat
Sorry for that
Andy Holland
@AMHOL
Aug 11 2016 15:26
xD
It's all good
Do the same sometimes too, think there's some bugs with gitter where the header and right sidebar are for one room but the chat is for another
Jānis Miezītis
@janjiss
Aug 11 2016 15:57
When you click on the left sidebar, on rom-rb, but it does not open the room of that organisation until you explicitly do that. :(
Sean Collins
@cllns
Aug 11 2016 15:58
@janjiss yea, I have this problem with Gitter too 😦
Piotr Solnica
@solnic
Aug 11 2016 18:34
gitter is VERY buggy
I hope they will do something about that eventually
Steve
@dnd
Aug 11 2016 20:39
I have some structs defined using Types::Maybe::Coercible::Int, and instead of the values coming through as an int(even if present), I just get a representation of something like Some(1)
this value can't be cast using to_i, nor can it be compared with another value such as user.id == 1
am I misunderstanding how Maybe/Coercible types are supposed to be used?
Jānis Miezītis
@janjiss
Aug 11 2016 20:40
It’s a monad. If you want to use maybe type you will have to unwrap the value by calling .value.to_i on it or fmap {|v| v.to_i}
Check dry-monads gem if you want to use them
Does that make sense?
Steve
@dnd
Aug 11 2016 20:42
@janjiss is there any way to have an optional value representation wthout having to resort to calling #value to actual use the value?
Jānis Miezītis
@janjiss
Aug 11 2016 20:42
You can do Types::Nil | Types::Maybe::Int
sorry
Types::Nil | Types::Coercible::Int
You can also call Types::Coercible::Int.optional
Steve
@dnd
Aug 11 2016 20:44
@janjiss awesome, that works. What is the benefit of using the monad version? Does it tie in somewhere else in the dry libraries?
Nikita Shilnikov
@flash-gordon
Aug 11 2016 20:44
@dnd if you use maybe values, it's always gonna be a monad, another kind of object, with different interface
Jānis Miezītis
@janjiss
Aug 11 2016 20:45
@dnd It’s heavily used in many dry- rom- libraries as far as I am aware
Nikita Shilnikov
@flash-gordon
Aug 11 2016 20:45
main benefit of using is it requires you to be explicit when you deal with nullable values
Piotr Solnica
@solnic
Aug 11 2016 20:46
we use monads mainly in dry-transaction and dry-matcher
it’s a really nice foundation for these two
rom-rb doesn’t use any monads
Nikita Shilnikov
@flash-gordon
Aug 11 2016 20:46
so if you're doing it right, you won't have no_method_errors and such
Jānis Miezītis
@janjiss
Aug 11 2016 20:47
@dnd You can essentially defer nullable values to be dealt with at the end of your operation. + some other good benefits. Check Tom Stuarts talk on this: https://www.youtube.com/watch?v=J1jYlPtkrqQ
Nikita Shilnikov
@flash-gordon
Aug 11 2016 20:48
rom-rb does not use them internally, but it relies on dry-t, which in order has dry-monads as a depdendenct
Piotr Solnica
@solnic
Aug 11 2016 20:48
aah I really like this talk
Nikita Shilnikov
@flash-gordon
Aug 11 2016 20:49
so you can use maybe types in relation schemas for example
though they won't play nice when you'll try to write values, I believe
Jānis Miezītis
@janjiss
Aug 11 2016 20:52
Oh, nice. Importing 15000 k CSV records with rom and dry-types structs took about 12 seconds
Steve
@dnd
Aug 11 2016 20:52
I think I watched that presentation some time last year. I probably need to go back and rewatch it
thanks for the help and info guys
Jānis Miezītis
@janjiss
Aug 11 2016 20:55
@dnd Welcome :)