These are chat archives for dry-rb/chat

Aug 2018
Aug 08 2018 03:33
Could it be said that ruby-rack is any kind of recursive monad?
Tim Riley
Aug 08 2018 03:35
I don’t think so
Tim Riley
Aug 08 2018 03:40
it more that rack implements something akin to a pipeline design pattern
Aug 08 2018 03:49
yep, thnx, "To be considered a monad the structure has to provide three components:..."
Maciej Mensfeld
Aug 08 2018 07:45
Anyone any help with my question?
Piotr Solnica
Aug 08 2018 07:58
@mensfeld you can't do it, this is something I want to improve it in 1.0.0. As an alternative, you can use two schemas
Alexey Zhaboyedov
Aug 08 2018 11:27
@flash-gordon , yesterday I published one issue with Dry::Monads::List::Validated and prepared a quick fix for it.
May I ask you to review corresponding PR dry-rb/dry-monads#66 , please?
Thank you in advance!
Vasily Kolesnikov
Aug 08 2018 14:18

Hi folks!
How to understand this behaviour:

 >> Dry::Types['float'][1]                                                                                                                                                                                   
 => 1                                                                                                                                                                                                        
 >> Dry::Types['float'].constrained(gteq: 1.0)[1]                                                                                                                                                              
 Dry::Types::ConstraintError: 1 violates constraints (1 must be an instance of Float failed)                                                                                                                 
 from /Users/v.kolesnikov/.rvm/gems/ruby-2.5.0/gems/dry-types-0.13.2/lib/dry/types/constrained.rb:28:in `block in call'

Why the first type definition doesn't check the actual type of value? But the constrained does.

Igor S. Morozov
Aug 08 2018 14:26

Dry::Types[‘float’] is just a definition which is not really usable for anything except type annotation.

When you use .constrained, it creates a Dry::Types::Constrained on top of the old type. IIRC, there are two kinds of constrained types: strict and coercible (available under Dry::Types::Constrained::Coercible)

Piotr Solnica
Aug 08 2018 14:29
hmmm, no, this looks like a bug <= this calls Definition#try and it returns a failure object, which later on is raised as a constrained error :/
@v-kolesnikov please report this as a bug, I'm not sure how to fix it tbh
maybe we should not allow #constrained on plain definitions, not sure
Vasily Kolesnikov
Aug 08 2018 14:33
ok, I'll send issue later today.