« Back to channel list

#ruby-offtopic - 23 October 2017

« Back 1 day Forward 1 day »
[00:15:43] Technodrome: has joined #ruby-offtopic
[00:43:24] nofxx: has joined #ruby-offtopic
[00:44:35] leah2: but a set doesn't have a length :p
[00:55:20] nofxx: has joined #ruby-offtopic
[00:55:56] baweaver: Well, two papers submitted so now it's time to practice Lemur-based programming tutorials :D
[00:56:20] baweaver: The first three will be very n00b level: Map, Select, Find
[00:56:57] baweaver: Namely because I want to focus on being clear and concise on simple subjects before I go whole-hog on it.
[01:05:05] nofxx: has joined #ruby-offtopic
[01:06:49] nofxx: has joined #ruby-offtopic
[01:15:15] nofxx: has joined #ruby-offtopic
[01:17:52] nofxx: has joined #ruby-offtopic
[01:57:03] workmad3: has joined #ruby-offtopic
[03:47:58] Technodrome: has joined #ruby-offtopic
[04:57:09] workmad3: has joined #ruby-offtopic
[05:31:01] Technodrome: has joined #ruby-offtopic
[06:05:15] apeiros: has joined #ruby-offtopic
[06:05:15] dminuoso: leah2: Finite sets at least do?
[06:23:31] Mon_Ouie: has joined #ruby-offtopic
[06:57:53] workmad3: has joined #ruby-offtopic
[07:10:43] apeiros: has joined #ruby-offtopic
[07:18:10] baweaver: Transducers
[07:18:27] baweaver: (this - https://medium.com/@roman01la/understanding-transducers-in-javascript-3500d3bd9624 )
[07:19:02] baweaver: What if Enumerable -> Transducible
[07:19:34] baweaver: Trans(array).map {}.select {}.etc ... -> auto-transduction
[07:20:19] havenwood: baweaver: I wanted to just have Enumerable methods take an optional first and second argument for collection and reducing operation.
[07:20:24] baweaver: Then Benchmark time :D
[07:20:58] havenwood: [1, 2, 3].map($stdout, :puts) { |n| n + 42 }
[07:21:14] dminuoso: baweaver: Transducible?
[07:21:20] dminuoso: Is that a new protocol/typeclass/concept?
[07:21:26] baweaver: Basically make it behave like Enumerable
[07:21:36] baweaver: except it automatically transduces functions with the same syntax
[07:23:12] baweaver: No intermediate arrays chaining Enumerable functions
[07:23:22] dminuoso: baweaver: You know, if you want call-by-need, just use Haskell?
[07:23:25] baweaver: without the need for lazy
[07:24:54] matthewd: How does it differ from lazy? :/
[07:25:09] baweaver: Read ze link
[07:27:20] dminuoso: baweaver: Bah this is so hard to read without type annotations.
[07:27:36] dminuoso: This is why JS developers need to be shot on sight.
[07:27:43] dminuoso: Especially when they start doing FP
[07:27:58] baweaver: zealotry is rarely productive
[07:28:28] baweaver: well if I get into RubyConfAU that's the end goal of the talk
[07:29:02] baweaver: except I explain it with cartoons and build up more to it
[07:29:18] baweaver: Also may have just squatted on transducible as a gem name
[07:29:21] baweaver: because reasons
[07:29:22] dminuoso: baweaver: Please don't use inline function definitions like that article.
[07:29:30] dminuoso: https://gist.github.com/anonymous/683af875a65eae3d9d9412495a7ec7df
[07:29:38] baweaver: Yeah, I'm not fond of those either
[07:30:12] baweaver: It falls under 1-liner rules for me
[07:30:18] baweaver: just because you can does not mean you should
[07:32:31] matthewd: Is this what you mean? Trans(array).map {|n| n + 1 }.select {|n| n % 2 == 0 }.to_a # => [2, 4, 6, 8, 10]
[07:33:03] baweaver: Trying to find a way to do it without a wrap, but don't think it's possible
[07:33:28] matthewd: And `Trans(array).map {|n| p [:map, n]; n + 1 }.select {|n| p [:select, n]; n % 2 == 0 }.to_a` would alternate :map, :select, etc.
[07:33:29] baweaver: The difference is that lazy sends values through one at a time. Transduction composes every single one of the functions into one
[07:34:00] matthewd: .. how can you tell the difference?
[07:34:20] baweaver: http://jlongster.com/Transducers.js-Round-2-with-Benchmarks
[07:36:15] dminuoso: baweaver: Is that compose the wrong way in that code at the beginning?
[07:36:33] kapil___: has joined #ruby-offtopic
[07:36:33] baweaver: Didn't read it very carefully.
[07:37:31] matthewd: dminuoso: Then it's not a technique to be learned, it's an improvement to be made to the runtime
[07:37:57] dminuoso: matthewd: I fully agree with you.
[07:38:23] dminuoso: matthewd: To me this is just an optimization of code in HNF.
[07:38:41] dminuoso: Well, WHNF.
[07:39:57] baweaver: ACTION just wants to see what this benchmarks to in Ruby
[07:41:24] matthewd: I'm dubious that the benchmarks will match up.. the internal distinction feels like it might only matter to a runtime that can do inlining, to me
[07:42:14] baweaver: More of curious to see how it works than anything.
[07:56:48] mikecmpbll: has joined #ruby-offtopic
[08:58:27] workmad3: has joined #ruby-offtopic
[09:04:01] workmad3: has joined #ruby-offtopic
[11:12:55] Mon_Ouie: has joined #ruby-offtopic
[12:29:24] workmad3: has joined #ruby-offtopic
[12:50:55] dminuoso: havenwood: https://gist.github.com/anonymous/5f84dbb513acc79447a8b2413660a9d8
[12:51:07] dminuoso: Need to dry this up a little.
[13:00:49] matthewd: dminuoso: Move arity_range up to the module, then include it in the refinements
[13:15:45] dminuoso: Oh yeah I can just stuff that into an anonymous module.
[13:16:02] matthewd: No need -- just use the module that's already there
[13:23:31] matthewd: dminuoso: https://gist.github.com/matthewd/50c5f30aa833fb0396cde4c614b86e07
[13:24:09] dminuoso: matthewd: I didn't consider this possible.
[13:24:27] matthewd: (note I changed a bunch more than just that)
[13:25:00] matthewd: I had no idea, tbh.. I just went with "it'd be handy if I could.." :)
[13:25:26] workmad3: has joined #ruby-offtopic
[13:30:47] dminuoso: matthewd: Interesting, you hit the nail on the head with that. I like it.
[13:37:11] matthewd: dminuoso: Also consider moving the Nothing-specific behaviour to singleton methods
[13:40:46] dminuoso: matthewd: What do you mean?
[13:41:46] matthewd: https://gist.github.com/matthewd/c80811d6231d62412b0dc7f7fa21f8a9
[13:42:45] dminuoso: Ah, that cleans it up considerably more.
[13:44:25] matthewd: Objects and inheritance: Not Always Terrible ;)
[13:45:55] matthewd: I think that surreptitiously stamps out the last of the camel-casing, too :P
[13:47:27] nofxx: has joined #ruby-offtopic
[13:52:14] dminuoso: matthewd: If only we could use things like ' in identifiers :(
[13:52:39] dminuoso: Though the Nothing = new(nil) is incorrect.
[13:52:45] dminuoso: I made that mistake in the beginning too.
[13:52:50] dminuoso: Just nil != Nothing.
[13:53:01] dminuoso: for example:
[13:53:19] dminuoso: Maybe.of(nil).fmap(->(e) { e.nil? })
[13:53:27] matthewd: I overrode the things that cared about that
[13:53:54] matthewd: It has to pass something just because I'm reusing the class, but the value is immaterial. It could be :lol_nope if you like.
[13:54:04] matthewd: Or even better, actually: Object.new
[13:54:19] matthewd: That way it's guaranteed not to look like anything else, if it does somehow leak out
[13:54:27] dminuoso: Right, so if I provide some mechanism to deconstruct a Just value, I'd just override this in the singleton class of Nothing to say raise.
[13:55:00] dminuoso: I guess Ruby is not horrible after all. :D
[13:55:03] matthewd: The Object.new version would save you from needing a Nothing-specific == method, at least
[13:55:37] dminuoso: matthewd: Yeah, and it still is_a? Maybe
[13:56:20] matthewd: Yeah -- that's basically the only reason to keep the inheritance, as it currently stands
[13:57:39] dminuoso: matthewd: In Haskell you can do all of this with just `data Maybe a = Just a | Nothing deriving (Eq, Ord)` :(
[13:58:30] dminuoso: I mean creating that kind of disjoint union of "Nothing" and "Just"
[13:59:35] dminuoso: Though with the presence of the safe navigation operator, Maybe is not that useful unless you use it as an applicative or monad.
[13:59:45] dminuoso: In Ruby I mean.
[14:00:21] matthewd: Yeah; one could make the argument that nil already is Nothing
[14:03:06] matthewd: The shortest I can get in ruby would be something like `Maybe = Module.new; Just = Struct.new(:a) { include Maybe }; Nothing = Class.new { include Maybe }`
[15:01:50] dminuoso: matthewd: Nothing = Module.new { include Maybe }
[15:02:12] matthewd: extend, but yeah, that is better
[15:02:16] dminuoso: Or do you intend to use Nothing as a constructor to build new objects from? (which would also be fine)
[15:03:27] matthewd: I think I was just following the most direct rubification of the haskell version
[15:05:12] matthewd: Where I think I would contend that `Nothing` in a value position is much closer to `Nothing.new` in ruby than a reference to a `Nothing` singleton -- even though both it and Just are really nothing like either of the above once the compiler gets its hands on them
[15:09:48] guacamole: has joined #ruby-offtopic
[15:32:34] Technodrome: has joined #ruby-offtopic
[15:38:39] havenwood: dminuoso: Nice!'
[15:51:08] dminuoso: havenwood: Do you know of a way of detecting whether a method will bind a block?
[15:51:34] havenwood: dminuoso: no, but I wish I did
[15:51:38] dminuoso: havenwood: I do! :D
[15:51:43] havenwood: dminuoso: pray tell!
[15:51:43] dminuoso: But it's ugly.
[15:51:51] matthewd: Disassemble it? :|
[15:52:24] dminuoso: matthewd: Yeah.
[15:52:31] dminuoso: It will only work for ruby land methods, but meh.
[15:53:35] dminuoso: >> class Foo; def bar(&blah); end; end; puts RubyVM::InstructionSequence.of(Foo.instance_method(:bar)).disasm
[15:53:36] ruby[bot]: dminuoso: # => == disasm: #<ISeq:bar@/tmp/execpad-e4290cf29974/source-e4290cf29974>==== ...check link for more (https://eval.in/885262)
[15:54:50] matthewd: There's also eval, binding, and outside of stdlib, the impossible-to-detect binding-of-caller
[15:55:47] dminuoso: I mean for this particular purpose, it's fairly fine really.
[15:55:52] matthewd: (assuming you want to know about use of yield/block_given?, and not only &block)
[15:56:42] dminuoso: matthewd: Yeah, hence the idea of disassembling. yield/block_given? or a <Block> type local entry is enough to infer that the method somehow expects a block.
[15:57:07] dminuoso: Not sure how eval/binding/binding-of-caller would help
[15:57:32] dminuoso: For this purpose only covering ruby-land is fine actually.
[15:57:34] matthewd: They don't help -- they provide ways the method might use a block when you think it won't
[15:57:54] dminuoso: matthewd: how do you mean?
[15:58:32] matthewd: def foo; eval("yield"); end
[16:00:18] dminuoso: matthewd: I could provide a way of decorating the class in a way to opt-out of specific requirements.
[16:01:03] dminuoso: Or simply not care and force those users to delegate to another method if they want to do some shenanigans.
[16:06:20] Technodrome: has joined #ruby-offtopic
[16:20:59] guacamole: has joined #ruby-offtopic
[16:29:00] guacamole: has joined #ruby-offtopic
[16:29:03] apeiros_: has joined #ruby-offtopic
[16:31:37] guacamole: has joined #ruby-offtopic
[17:00:17] eckhardt: has joined #ruby-offtopic
[17:08:10] nofxx: has joined #ruby-offtopic
[17:43:17] mikecmpbll: has joined #ruby-offtopic
[17:57:17] guacamole: has joined #ruby-offtopic
[18:57:19] eckhardt: has joined #ruby-offtopic
[19:42:44] Technodrome: has joined #ruby-offtopic
[19:45:06] guacamole: has joined #ruby-offtopic
[19:59:58] eckhardt: has joined #ruby-offtopic
[20:21:05] eckhardt: has joined #ruby-offtopic
[21:25:05] apeiros_: has joined #ruby-offtopic
[22:23:02] workmad3: has joined #ruby-offtopic
[22:31:31] eckhardt: has joined #ruby-offtopic
[23:45:38] eckhardt: has joined #ruby-offtopic
[23:46:50] mikecmpbll: has joined #ruby-offtopic
[23:51:58] eckhardt: has joined #ruby-offtopic