Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Benjamin Klotz
@tak1n
hehe :P
u are using kleisli under the hood right?
love unneeded questions xD
Piotr Solnica
@solnic
@tak1n yeah, I like kleisli
Benjamin Klotz
@tak1n
awesome :D
Piotr Solnica
@solnic
hey so maybe (no pun intended) we should switch to namespaced names?
Andy Holland
@AMHOL
+1
Piotr Solnica
@solnic
”strict.string” ”maybe.string” ”form_input.maybe.string”
Andy Holland
@AMHOL
here
Benjamin Klotz
@tak1n
+2
:D
Piotr Solnica
@solnic
holy moly I’m gonna love this lib (self-biased optimism)
Andy Holland
@AMHOL
:joy:
@solnic worth defining constants?
Piotr Solnica
@solnic
I don’t think we need constants
Andy Holland
@AMHOL
Dry::Data::STRICT_STRING = 'strict.string'.freeze
Dry::Hash.new(name: STRICT_STRING)
Piotr Solnica
@solnic
it’s gonna be more words to type
Benjamin Klotz
@tak1n
less string allocs
:D
Andy Holland
@AMHOL
That was my thinking
Benjamin Klotz
@tak1n
premature opt :D
Andy Holland
@AMHOL
lol
Piotr Solnica
@solnic
it’s gonna be better in mri 3.0 ;)
Andy Holland
@AMHOL
:laughing:
Piotr Solnica
@solnic
OPTIMIZE FOR THE UNKNOWN FUTURE ;)
Andy Holland
@AMHOL
mri 3.0 is gonna be Perl 6
Piotr Solnica
@solnic
luls
@AMHOL nice work on roda-flow, did you start using it in your project after all?
Andy Holland
@AMHOL
Yeah
Piotr Solnica
@solnic
cool man
Andy Holland
@AMHOL
It's working out nicely
Only a simple app though
Piotr Solnica
@solnic
Type.new(method(:constructor).to_proc.curry.(primitive), primitive) HATERS GONNA HATE ;)
Andy Holland
@AMHOL
lol
Benjamin Klotz
@tak1n
primitives, primitives everywhere
xD
@solnic I think I'll use dry validator for these use case specific validation rules I mentioned earlier
Piotr Solnica
@solnic
@tak1n not sure if @AMHOL released it already :)
Andy Holland
@AMHOL
I haven't
Wanted to add more built-in validations, but haven't had time or enthusiasm to work on stuff lately
Feel free to release it as-is though
Piotr Solnica
@solnic
I’ll be working on it after dry-data is released and usable
Piotr Solnica
@solnic
irb(main):009:0> t = Dry::Data.method(:[])
irb(main):010:0> maybe_coercible_string = t.('strict.nil') | t.('coercible.string')
irb(main):011:0> maybe_coercible_string[nil]
=> None
irb(main):012:0> maybe_coercible_string[123]
=> Some("123")
oh haters gonna hate so much <3
Andy Holland
@AMHOL
Lol
Does None pass a nil check?
Piotr Solnica
@solnic
@AMHOL nope it doesn't pretend to be a nil
Andrew Kozin
@nepalez

@AMHOL @solnic As far as i inderstood, you've implemented namespace in dry-container as... well, namespace :)
I mean, it seems like a syntax sugar for long keys like "namespace.name" added via namespaced(key) method, innit?

I think, why not (re)implement it as a nested container(s), whose methods are available from the "parent" container via nested name.
This would allow importing "namespaces - containers" from one to another. Like in case:

foo = Dry::Container.new
foo.namespace(:bar) do
  register(:baz) { :BAZ }
end

qux = Dry::Container.new do
  import foo.namespace(:bar), as: :fbar # here resolve has to be reloaded to work with both variables and namespaces
                                        # also namespace w/o block would just return the namespace
end

qux.resolve("fbar.baz") # => :BAZ

I think about this feature in connection to dry-data. When I read dry-data, the first thing I asked myself is: how to take some types defined inside one module and inject them to another. Just like in Haskell:

import Data.Char (toLower, toUpper)

or in transproc (the same haskell-inspired mechanism)

import :camelize, from: Inflecto, as: :up