flash-gordon on main
Ignore compat.rb in Zeitwerk lo… Add more paths to loader exclus… Add spec to test eager loading and 1 more (compare)
Hi, I've been thinking about opening a pull request for dry-struct
to make it quack a bit more like a hash in order to enable validating it with dry-validation
. Nowadays an attempt to call a schema with a struct object throws an error. I don't understand if this is a conscious design decision because it seems like a useful use case.
What I want to enable is this:
schema = Dry::Validation.Schema { required(:age).filled(gteq?: 18) }
User.new(age: 17)
schema.(user)
#<Dry::Validation::Result output=#<User age=17> errors={:age=>["must be greater than or equal to 18"]}>
Another question, then
BMI = Dry::Types['strict.int'].constrained(gteq: 18, lteq: 42).constructor { |x| x.round }
BMI[17.5]
#=> 18
BMI.valid?(17.5)
#=> false
Does this behavior make sense or is it a bug?
fn
to value
. Doesn't it seem wrong?
sequence
signature is: F[G[A]] -> G[F[A]]
traverse
acts as sequence
https://github.com/dry-rb/dry-monads/blob/master/lib/dry/monads/list.rb#L263-L286
hum maybe this is better:
future_rows = Dry::Monads::List.[]
requests.find_in_baches { |data|
future_rows += Task[:io] { compute_rows(data) }
}
future_rows.traverse { |rows|
…
}
WDYT ?
Monads::List
isn't meant to be mutable
future_rows = []
coerce
?
List.new
, it's O(1)