These are chat archives for dry-rb/chat

18th
Aug 2015
Andy Holland
@AMHOL
Aug 18 2015 07:47
@solnic feel free to merge ^ if it helps, will implement importable namespaces tonight
Andy Holland
@AMHOL
Aug 18 2015 08:04
Got dryrb/dry-container#5, just needs specs
I like the DSL pattern BTW, copied that from ROM :p
Piotr Solnica
@solnic
Aug 18 2015 08:53
you’re not a tdd person?
Andy Holland
@AMHOL
Aug 18 2015 08:53
Nah
I like to hack to shit then write tests later
Well, I'm not keen on writing tests, I do it to follow convention :laughing:
Piotr Solnica
@solnic
Aug 18 2015 08:53
easier to hack tests and hack less shit :)
I hear you, I was there myself, it takes time
Andy Holland
@AMHOL
Aug 18 2015 08:54
I guess I feel like writing tests takes the fun out of writing code
Piotr Solnica
@solnic
Aug 18 2015 08:54
this sounds awfuly familiar ;)
Andy Holland
@AMHOL
Aug 18 2015 08:55
:p
You felt the same?
Piotr Solnica
@solnic
Aug 18 2015 08:55
yes
Andy Holland
@AMHOL
Aug 18 2015 08:55
Actually reading, and taking in the transflow article now, it's a really good one :)
Piotr Solnica
@solnic
Aug 18 2015 08:56
I was like “OMG IMPLEMENTATION APPROACHING YADA-YADA-YADA…uh shit now I gotta write tests"
Andy Holland
@AMHOL
Aug 18 2015 08:56
lmao inorite
Piotr Solnica
@solnic
Aug 18 2015 08:56
:)
Andy Holland
@AMHOL
Aug 18 2015 08:57
I like that moment when you're like "But what if you want to update a user?" then it all falls into place and makes perfect sense
Piotr Solnica
@solnic
Aug 18 2015 08:57
hah thanks! yeah not a single “omg this is stupid I don’t understand it you better go write in statically typed, fn language”-comments on reddit :)
Andy Holland
@AMHOL
Aug 18 2015 08:58
:joy:
Piotr Solnica
@solnic
Aug 18 2015 08:58
it always makes me sad when people are dissing me without asking any good questions :(
Andy Holland
@AMHOL
Aug 18 2015 08:58
haters gonna hate
Piotr Solnica
@solnic
Aug 18 2015 08:59
I’m close to porting hairy parts of my app to transflow, I just found an issue with publishers + currying, I mean not an issue, a missing feature, so I’ll add that one and then I should be able to completely switch to transflow for my use-cases
I’ve been thinking about flow control w/o exceptions
we could introduce some result objects I suppose
Andy Holland
@AMHOL
Aug 18 2015 09:00
Yeah, I tend to avoid raising exceptions for user errors
I always felt it was more of an interface to alert the developer to errors rather than the user, if that makes sense
Piotr Solnica
@solnic
Aug 18 2015 09:00
notice that it’s an exception inside a transaction that you can handle using normal code
yeah, me too, although I’ve been on the fence with that for a while
I understand the arguments but then I see that it’s so much simpler to just use a freaking exception, you know
Andy Holland
@AMHOL
Aug 18 2015 09:01
lol yeah
Piotr Solnica
@solnic
Aug 18 2015 09:01
but then I feel like I just used GOTO in ruby
:joy:
Andy Holland
@AMHOL
Aug 18 2015 09:01
haha I feel you
Piotr Solnica
@solnic
Aug 18 2015 09:02
but I’m quite OK with adding custom response objects to control the flow
esp if it would allow not breaking the transaction
and introducing safe-points etc
I also plan to add an interface for rollbacks
Andy Holland
@AMHOL
Aug 18 2015 09:02
Yeah, maybe sth like unsound?
Nice
brb :smoking:
Piotr Solnica
@solnic
Aug 18 2015 09:02
oh and of course transactions should support nesting
they respond to call() after all
I gotta “run" focus on code, got a lot to do in prep for rom 0.9.0
I’ll check out namespaces afternoon when I’ll be actually trying to use that in my app :)
Andy Holland
@AMHOL
Aug 18 2015 09:15
Cool :)
Andy Holland
@AMHOL
Aug 18 2015 09:29
Twitter oauth is a pain in the arse :anger:
Piotr Solnica
@solnic
Aug 18 2015 10:39
oauth is PITA in general
horrible to test
anyhow, I just finished porting my apps hairy controller actions to transflow
Andy Holland
@AMHOL
Aug 18 2015 10:39
Cool, how was it?
Piotr Solnica
@solnic
Aug 18 2015 10:40
well, it was the first step, I still have controllers being used as event listeners which I want to get rid of as the second step
Andy Holland
@AMHOL
Aug 18 2015 10:41
Ahh OK
Piotr Solnica
@solnic
Aug 18 2015 10:41
but I was able to a) split the complex logic into smaller junks w/o pain b) split additional behavior into event listeners c) re-use a ton of code easily between 2 controllers
Andy Holland
@AMHOL
Aug 18 2015 10:41
Yeah, I can see how that would work from the blog post
Kind of like the benefits with roda, but encapsulated into nice little command-like procs
Piotr Solnica
@solnic
Aug 18 2015 10:42
one of the cool aspects of this approach is that you can easily plug-in additional behavior w/o even touching code that uses a given transaction
Andy Holland
@AMHOL
Aug 18 2015 10:43
Yeah, I need to use it at some point :p
Piotr Solnica
@solnic
Aug 18 2015 10:43
anyhow, I start to see how custom result objects and avoiding exceptions for control flow would makes things nicer
so that’s something to do for 1.0.0 for sure, I think
Andy Holland
@AMHOL
Aug 18 2015 10:43
Just hard to introduce new concepts at work with such a lot of existing code/practices
Piotr Solnica
@solnic
Aug 18 2015 10:43
I hear you
Andy Holland
@AMHOL
Aug 18 2015 10:43
Will #import help with your container problem BTW?
Piotr Solnica
@solnic
Aug 18 2015 10:44
yeah, about that
I will work on it right now
so will give you feedback in ~half an hour
Andy Holland
@AMHOL
Aug 18 2015 10:44
Nice :D
Thanks
Piotr Solnica
@solnic
Aug 18 2015 11:07
@AMHOL how do I use ns + import?
Piotr Solnica
@solnic
Aug 18 2015 11:21
well, it works :)
Andy Holland
@AMHOL
Aug 18 2015 11:24
:D
Figured it out then
Piotr Solnica
@solnic
Aug 18 2015 11:26
didn’t use import yet though
Andy Holland
@AMHOL
Aug 18 2015 11:26
Ahh OK
ns = Dry::Container::Namespace.new('repositiories') do
  register('user') { ThreadSafe::Array.new }
end
container = Dry::Container.new
container.import(ns)

container.resolve('repositories.user') # => []
Piotr Solnica
@solnic
Aug 18 2015 11:32
an done, all green
I managed to do it w/o import
Andy Holland
@AMHOL
Aug 18 2015 11:32
Nice :D
How did you end up doing it?
Piotr Solnica
@solnic
Aug 18 2015 11:34
nesting, so meh, but works
second step will be to use import
holy moly it worked
Piotr Solnica
@solnic
Aug 18 2015 11:41
dude, it works so freaking well
Andy Holland
@AMHOL
Aug 18 2015 11:43
:D
Found a bug with import
Piotr Solnica
@solnic
Aug 18 2015 11:44
my app is working, ported everything to use namespaces + import
looks fantastic
Andy Holland
@AMHOL
Aug 18 2015 11:44
Cool
Andy Holland
@AMHOL
Aug 18 2015 12:00
@solnic that's in master now
Probably release as 0.2.2 tonight
Piotr Solnica
@solnic
Aug 18 2015 12:05
ok, I’ll switch to master
I’d appreciate a release
Andy Holland
@AMHOL
Aug 18 2015 12:36
@solnic looking to create dry-injector soon, think we could start off with your implementation?
Piotr Solnica
@solnic
Aug 18 2015 12:39
uhm
NO
:D
Andy Holland
@AMHOL
Aug 18 2015 12:40
lol
Is it still the same as before?
Piotr Solnica
@solnic
Aug 18 2015 12:44
yes
Andy Holland
@AMHOL
Aug 18 2015 12:44
Ahh OK
Piotr Solnica
@solnic
Aug 18 2015 12:44
major hack
Andy Holland
@AMHOL
Aug 18 2015 12:44
Yeah, it's gonna be difficult to get something that isn't without only resolving dependencies when you resolve from the container
Which, without writing a framework, won't work too well
Piotr Solnica
@solnic
Aug 18 2015 12:53
let’s write a framework
we’ve got the pieces
only a matter of putting them together
Andy Holland
@AMHOL
Aug 18 2015 12:53
Seriously?
Sounds good to me (BTW)
Piotr Solnica
@solnic
Aug 18 2015 12:53
yeah, that was serious
Andy Holland
@AMHOL
Aug 18 2015 12:53
I'm game
router, routing tree or sth new?
Piotr Solnica
@solnic
Aug 18 2015 12:55
I was hoping we could reuse roda stuff :)
you were thinking about sth brand new from scratch
?
Andy Holland
@AMHOL
Aug 18 2015 12:55
Yeah
Could build on roda
But we would either have to be unobtrusive and use plugins or fork it :laughing:
Pretty sure it would end up forked
:joy:
Piotr Solnica
@solnic
Aug 18 2015 13:02
really? did you look into that enough to have doubts? (I have not)
Andy Holland
@AMHOL
Aug 18 2015 13:03
Nah, just a guess :p
Piotr Solnica
@solnic
Aug 18 2015 13:04
I am fine with that
just like I was fine with using Sequel as the backend for rom-sql
Andy Holland
@AMHOL
Aug 18 2015 13:04
Fair do
Piotr Solnica
@solnic
Aug 18 2015 13:04
I know it’s not the best thing to do but it’s the best thing that was possible to use immediately
so, my hunch is that re-using Roda would work well enough
there are many concepts I’d like to try out
I don’t need to build a framework from the ground up
to do so
Andy Holland
@AMHOL
Aug 18 2015 13:05
It's just I've been thinking about the plugin system, and I kind of see it as sugar around monkey-patching :see_no_evil:
:runner:
Piotr Solnica
@solnic
Aug 18 2015 13:06
in roda?
Andy Holland
@AMHOL
Aug 18 2015 13:06
Yeah
Piotr Solnica
@solnic
Aug 18 2015 13:06
huh, weird
Andy Holland
@AMHOL
Aug 18 2015 13:06
?
Piotr Solnica
@solnic
Aug 18 2015 13:06
Jeremy wrote that it’s the next generation after Sequel
so I just assumed it’s a nice thing :D
Andy Holland
@AMHOL
Aug 18 2015 13:06
:laughing:
Piotr Solnica
@solnic
Aug 18 2015 13:07
rom’s plugin system could be used as a sugar for monkey-patching too :)
Andy Holland
@AMHOL
Aug 18 2015 13:07
What about DI, and composable behaviour, rather than just expanding an objects interface
Piotr Solnica
@solnic
Aug 18 2015 13:07
that’s precisely how I try to use plugin system in ROM
Andy Holland
@AMHOL
Aug 18 2015 13:07
That's why I :runner: :joy:
Piotr Solnica
@solnic
Aug 18 2015 13:07
see pagination
it injects a paginator object
Andy Holland
@AMHOL
Aug 18 2015 13:08
Ahh, composition
Piotr Solnica
@solnic
Aug 18 2015 13:08
and extends the interface only with the min methods
yeah, composition
I think that’s the only sensible way
I’d like to try to build sth with roda
Andy Holland
@AMHOL
Aug 18 2015 13:09
Guess maybe I need to think about it more
Piotr Solnica
@solnic
Aug 18 2015 13:09
I think we should be able to quickly see if it’s a good option or not
Andy Holland
@AMHOL
Aug 18 2015 13:09
Yeah
Thought you built that site for your wife?
Piotr Solnica
@solnic
Aug 18 2015 13:09
do you have any ideas how to approach plugins in a different way?
oh yeah I did but it’s so simple
Andy Holland
@AMHOL
Aug 18 2015 13:10
Ahh ok
Piotr Solnica
@solnic
Aug 18 2015 13:10
I’ll be expanding it but first I need to assemble a custom stack
I want:
Andy Holland
@AMHOL
Aug 18 2015 13:10
No idea on the plugin front
Was thinking more no plugins
Piotr Solnica
@solnic
Aug 18 2015 13:11
1) IoC/DI built-in as the core feature and THE way of doing things
2) logic-less template rendering
3) stupid-simple data-view objects
4) sweet integration with rom (obviously)
5) ability to connect any object as an end-point handler
oh, and no helpers to render html, I hate it with passion
Andy Holland
@AMHOL
Aug 18 2015 13:12
lol
Piotr Solnica
@solnic
Aug 18 2015 13:12
I only want template rendering
thus I want template caching
Andy Holland
@AMHOL
Aug 18 2015 13:12
Yeah, small static method footprint as possible
Piotr Solnica
@solnic
Aug 18 2015 13:12
otherwise it’d be dead slow
Andy Holland
@AMHOL
Aug 18 2015 13:13
Point 5, you mean like controllers?
Piotr Solnica
@solnic
Aug 18 2015 13:13
one end-point, one object
Andy Holland
@AMHOL
Aug 18 2015 13:13
:+1:
Piotr Solnica
@solnic
Aug 18 2015 13:13
so I’m not sure if I want multi-end-points controllers
like in Rails
Andy Holland
@AMHOL
Aug 18 2015 13:13
Ahh OK
Piotr Solnica
@solnic
Aug 18 2015 13:14
and of course everything modelled as a flow of callable objects
Andy Holland
@AMHOL
Aug 18 2015 13:14
enforced or optional?
Piotr Solnica
@solnic
Aug 18 2015 13:14
not sure yet
probably optional BUT STRONGLY RECOMMENDED
:joy:
Andy Holland
@AMHOL
Aug 18 2015 13:15
:)
I think the best thing to do, would be to write a small app, as if the framework already existed
Do some real-world tasks and write our ideas of best-case interface
Then try to fill in the gaps?
Piotr Solnica
@solnic
Aug 18 2015 13:37
yes that’s a great way of discovering what we want :)
Andy Holland
@AMHOL
Aug 18 2015 13:52
@solnic https://github.com/trending?l=ruby first trending today
Piotr Solnica
@solnic
Aug 18 2015 14:05
@AMHOL tweeeeeted about it thanks :D
Andy Holland
@AMHOL
Aug 18 2015 14:18
No link? :laughing:
Piotr Solnica
@solnic
Aug 18 2015 14:46
@AMHOL I think I want to extract that pipeline operator into dry-*
dry-pipeline?
Andy Holland
@AMHOL
Aug 18 2015 14:47
Cool
Piotr Solnica
@solnic
Aug 18 2015 14:47
transproc is an overkill for transflow
Andy Holland
@AMHOL
Aug 18 2015 14:47
Works for me, unless you want something more generic for utilities?
Piotr Solnica
@solnic
Aug 18 2015 14:47
not to mention we have pipeline in ROM and Transproc
there’s a really horrible behavior right now where transproc rescues from any exception and raises its own “malformed input” error
I’m not sure why I agreed to adding that
Andy Holland
@AMHOL
Aug 18 2015 14:48
lol
Piotr Solnica
@solnic
Aug 18 2015 14:48
but it should go
this leads to code where something crashes because of a runtime error, like argument error etc
and you get an error from a library that input was malformed
this must go, asap
Andy Holland
@AMHOL
Aug 18 2015 14:50
Yeah, definite smell there
Piotr Solnica
@solnic
Aug 18 2015 14:50
we should probably rescue transproc call in rom-mapper
Andy Holland
@AMHOL
Aug 18 2015 14:50
As in rather than the transproc rescue?
Piotr Solnica
@solnic
Aug 18 2015 14:51
hmmmm
that would result in the same thing but in another library
Andy Holland
@AMHOL
Aug 18 2015 14:52
Yeah, that's what I was thinking
Piotr Solnica
@solnic
Aug 18 2015 14:52
thinking out loud, sorry :)
Andy Holland
@AMHOL
Aug 18 2015 14:52
:p
Piotr Solnica
@solnic
Aug 18 2015 14:52
trying to remember what was the reasoning behind adding this rescue
it’s hard to figure out that the input was invalid
but rescuing a system crash and saying that input was malformed is probably worse than having code simply blow up
not to mention that defining mappers means you’re using lower-level APIs and you gotta know what you’re doing
I’ve no idea why I’m discussing it in this channel :joy:
Andy Holland
@AMHOL
Aug 18 2015 14:54
:laughing:
PR has no indication of why
Search MalformedInputError in solnic/transproc
Piotr Solnica
@solnic
Aug 18 2015 14:56
so you’re ok with dry-pipeline?
Andy Holland
@AMHOL
Aug 18 2015 14:56
Yep
Piotr Solnica
@solnic
Aug 18 2015 14:56
cool
Andy Holland
@AMHOL
Aug 18 2015 14:56
I was leaning towards that rather than utils myself
@solnic you happy enough to nest it in the Dry module?
One of the ideas behind Dry was to try it's best to only leak Dry into global namespace (I know stuff depends on thread_safe but that was too good an opportunity to pass up)
Piotr Solnica
@solnic
Aug 18 2015 15:01
yes Dry::Pipeline
Andy Holland
@AMHOL
Aug 18 2015 15:01
:p my bad
Piotr Solnica
@solnic
Aug 18 2015 15:01
hm?
Andy Holland
@AMHOL
Aug 18 2015 15:01
so you’re ok withdry-pipeline?
Kind of obvious
Piotr Solnica
@solnic
Aug 18 2015 15:01
:)
Piotr Solnica
@solnic
Aug 18 2015 16:03
@AMHOL switched transflow to use dry-pipeline
Andy Holland
@AMHOL
Aug 18 2015 16:03
Wow, you don't fuck about :laughing:
Piotr Solnica
@solnic
Aug 18 2015 16:03
and fixed error handling, so now only descendants of StepError can stop pipeline
well, that wasn’t too difficult, mostly copy/paste :D
Andy Holland
@AMHOL
Aug 18 2015 16:05
That's a pretty sweet change, like the re-use of StepError in the example too :p
Piotr Solnica
@solnic
Aug 18 2015 16:05
which one?
lol
Andy Holland
@AMHOL
Aug 18 2015 16:20
@solnic out of interest, how come you made Dry::Pipeline an inclusion module rather than a class?
Would be nice to be able to do Dry::Pipeline.new ->(v) { v.upcase }
Could do the Dry::Pipeline::Mixin thing?
Piotr Solnica
@solnic
Aug 18 2015 16:28
@AMHOL I rushed
Andy Holland
@AMHOL
Aug 18 2015 16:28
:p
Piotr Solnica
@solnic
Aug 18 2015 16:43
wondering how to tackle response objects so that we can have nice control-flow based on those
maybe (no pun intended) kleisli could be used with its monads
Piotr Solnica
@solnic
Aug 18 2015 16:56
actually, we could integrate with some monadic interface easily
Andy Holland
@AMHOL
Aug 18 2015 19:04
Googles monads
Ahh OK :p
Still not seeing how useful this can be I think
Piotr Solnica
@solnic
Aug 18 2015 19:12
well, monads implement exactly the kind of interface we would have to implement ourselves if we wanted to control the flow w/o exceptions
check out this spec
@AMHOL ^^
it’s basically a way of not introducing any special interface in transflow and instead saying “ok, use kleisli monads for a nice control-flow w/o conditionals and exceptions"
when each operation return a monad you’re all set
to get the final result from a transaction you call #value on the resulting monad
publisher will still work so external listeners can be attached
Andy Holland
@AMHOL
Aug 18 2015 19:18
Ahh OK, so it's a functional if/else
Nice
Andy Holland
@AMHOL
Aug 18 2015 19:30
I wish attr_reader took a visibility modifier
@solnic would you put decorating an object into a flow or leave that external?
Piotr Solnica
@solnic
Aug 18 2015 20:20
@AMHOL wdym?
Andy Holland
@AMHOL
Aug 18 2015 20:20
Like wrapping in a presenter
Piotr Solnica
@solnic
Aug 18 2015 20:21
nah, a flow works well for complicated things
esp when dealing with errors is important
speaking of which, just ported one action to use monads, ridiculous simplification of the code
Andy Holland
@AMHOL
Aug 18 2015 20:22
Nice, that private or can you share it?
Piotr Solnica
@solnic
Aug 18 2015 20:22
private, work stuff
Andy Holland
@AMHOL
Aug 18 2015 20:22
Ahh OK
Piotr Solnica
@solnic
Aug 18 2015 20:23
but I’ll definitely write about this soooon
Andy Holland
@AMHOL
Aug 18 2015 20:23
So with monads, a flow can now have multiple paths of execution?
Rather than a single path with exit points?
Piotr Solnica
@solnic
Aug 18 2015 20:25
yes
depends on how you implement individual steps
Andy Holland
@AMHOL
Aug 18 2015 20:25
OK makes sense
Piotr Solnica
@solnic
Aug 18 2015 20:26
but every step can ignore a failure and become a noop or do something special
fwiw I don’t have that use case, so when one step return a failure then remaining ones are noops
Andy Holland
@AMHOL
Aug 18 2015 20:26
Yeah, makes sense for all the cases I can think of
Well, without including cases like wrapping errors in presenters
Andy Holland
@AMHOL
Aug 18 2015 20:31
@solnic where is Left and Right defined?
Piotr Solnica
@solnic
Aug 18 2015 21:04
it’s kleisli gem
Andy Holland
@AMHOL
Aug 18 2015 21:04
Ahh OK