workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
what i'm saying isn't that something should exist
2017-11-07T20:48:16.000262
Evelin
clojurians
clojure
its that something shouldn't exist
2017-11-07T20:48:22.000291
Evelin
clojurians
clojure
there shouldn't be an api for doing things "without transducers"
2017-11-07T20:48:32.000261
Evelin
clojurians
clojure
transducers are the bottom, simplest (most decomplected) case
2017-11-07T20:48:48.000161
Evelin
clojurians
clojure
eh, that's a position to take. it'd make the language less approachable though
2017-11-07T20:49:03.000182
Aldo
clojurians
clojure
<@Evelin> Do you know where Rich said that about reduce requiring an init val? I remember that as well, but I tried looking for it once and couldn't find it.
2017-11-07T20:50:12.000085
Giovanna
clojurians
clojure
And I think he has said that clojure 2.0 just isn't going to happen...
2017-11-07T20:50:48.000108
Giovanna
clojurians
clojure
there is something else i find a bit puzzling though-- we use transducers to convey what is basically loop unrolling to the compiler-- we really don't NEED then to pass around the idea of doing a specific sequence of transformations, because we could just use apply to apply a sequence of transformations or we could pass around an s-expression that represents the transformations
2017-11-07T20:51:00.000203
Evelin
clojurians
clojure
<@Giovanna> he mentions it in his effective programs talk
2017-11-07T20:51:04.000175
Evan
clojurians
clojure
basically i've been thinking and i'm trying to understand whether or not transducers are really ACTUALLY simple, or whether or not they are just an implementation detail
2017-11-07T20:51:31.000188
Evelin
clojurians
clojure
wouldn't a sufficiently intelligent compiler be able to inspect an s expression before evaluating it and rearrange its subexressions algebraically to do what transducers are effectively doing?
2017-11-07T20:52:07.000081
Evelin
clojurians
clojure
or heck, a macro could do that
2017-11-07T20:52:46.000028
Evelin
clojurians
clojure
the async library has really magical macros that tear apart s expressions
2017-11-07T20:53:01.000200
Evelin
clojurians
clojure
A macro is a compiler, in a way
2017-11-07T20:53:21.000053
Giovanna
clojurians
clojure
i'm just thinking that transducers, while they capture the idea of performing a computation independent of the type of the collection or data source, and in that sense are a basic fundamental thing, realistically aren't NECESSARY to extract the information about what sequence of transformations are actually taking place, since this is a lisp after all
2017-11-07T20:54:45.000162
Evelin
clojurians
clojure
i'm really not sure how I feel about it, its either transducers (and the initial difficulty in learning them) or the magic of a macro
2017-11-07T20:55:21.000325
Evelin
clojurians
clojure
imagine that if instead of having go channels take a transducer you just had something like `(magic (map f (filter g chan)))`, where `magic` is responsible for doing what transducers essentially do for chans
2017-11-07T20:57:03.000335
Evelin
clojurians
clojure
it would do all the unrolling itself, and ensure that you didn't have intermediate collections or channels
2017-11-07T20:57:43.000024
Evelin
clojurians
clojure
furthermore you can extend `magic` beyond what transducers are strictly capable of
2017-11-07T20:58:01.000281
Evelin
clojurians
clojure
you can use it with other (non transducible) forms
2017-11-07T20:58:13.000255
Evelin
clojurians
clojure
If you want to use transducers on a lazy source call `(sequence xfn coll)`
2017-11-07T20:58:46.000093
Guillermo
clojurians
clojure
(where `xfn` is the transducer)
2017-11-07T21:00:34.000196
Guillermo
clojurians
clojure
i'm aware of that <@Guillermo> i was just criticizing some of clojure's design
2017-11-07T21:01:01.000154
Evelin
clojurians
clojure
I think there is an option somewhere in between those. I was thinking about that the other day. Transducers are kind of ... fragile?... they have all these rules like don't touch the result so far, call the next rf in the chain in the cleanup arity, zero arity just calls (rf), etc. Could a macro kind of like `fn` take care of all that stuff instead of us having to write all that boilerplate?
2017-11-07T21:02:26.000027
Giovanna
clojurians
clojure
Rich has made it really clear that despite some regrets, compatibility will be preserved. There will not be any attempt to "fix mistakes" and break everyone's code. This is why it's important to commit to and promise less
2017-11-07T21:03:08.000040
Guillermo
clojurians
clojure
(see the "speculation" keynote)
2017-11-07T21:04:08.000173
Guillermo
clojurians
clojure
As always though, the future holds interesting possibilities...
2017-11-07T21:04:33.000088
Guillermo
clojurians
clojure
<@Giovanna>, there really aren’t that many types of transducers. it seems like it’s pretty uncommon to create a “new” transducer. out of curiosity, what kinds of transducers have you or others been creating that aren’t `map`, `filter`, `cat`, `dedupe`, etc?
2017-11-07T21:07:09.000016
Jonas
clojurians
clojure
Wouldn't your `magic` macro have to know about all possible transducers though? How would it know if something can be made into a transducer?
2017-11-07T21:07:33.000181
Giovanna
clojurians
clojure
<@Jonas> <https://github.com/cgrand/xforms>
2017-11-07T21:09:03.000017
Giovanna
clojurians
clojure
I mean i understand that one of the really great things about transducers is that you can construct your own transducers and then use them with any transducible process. My criticism about it is that it seems to expose some limitation in the implementation; its not purely about separating the sequence of transformations from the sequence (or channel or whatever) of data-- you could make that separation without creating the idea of a transducer, by just passing around function that is composed of the data processing functions for instance, then apply that function directly to the data.
2017-11-07T21:09:40.000152
Evelin
clojurians
clojure
<@Jonas> Also I wrote this one for someone here on the slack <https://gist.github.com/madstap/a7d158ef0c3e7b5bbf5cd55c5de4c913>
2017-11-07T21:11:36.000194
Giovanna
clojurians
clojure
<@Evelin>, `(map inc)`, `(filter even?)`, etc. seem like fairly minimal descriptions of a “step”
2017-11-07T21:12:26.000116
Jonas
clojurians
clojure
which part of `(map inc)` doesn’t need to be part of the transducer?
2017-11-07T21:12:44.000201
Jonas
clojurians
clojure
why even bother me with that though?
2017-11-07T21:13:05.000067
Evelin
clojurians
clojure
why can't i say `(map inc (filter even? (map inc foo)))`
2017-11-07T21:13:24.000124
Evelin
clojurians
clojure
why can't clojure do algebra to reorganize it
2017-11-07T21:13:32.000191
Evelin
clojurians
clojure
<@Evelin> But how would you do filter in that scheme? A function that returns nothing, as something separate from nil?
2017-11-07T21:13:37.000168
Giovanna
clojurians
clojure
how would you like it organized? currently, you can do `(comp (map inc) (filter even?) (map inc))`
2017-11-07T21:14:27.000196
Jonas
clojurians
clojure
Doing algebra in the compiler has a cost... That's what Haskell does
2017-11-07T21:14:31.000244
Guillermo
clojurians
clojure
There is also no clear definition in an impure language around what is pure vs impure, where can I move things around, etc
2017-11-07T21:15:06.000164
Guillermo
clojurians
clojure
Transducers aren't perfect, but the cost-benefit / leverage is off the charts high
2017-11-07T21:15:37.000129
Guillermo
clojurians
clojure
They were also implemented in user space, in a library initially
2017-11-07T21:16:05.000041
Guillermo
clojurians
clojure
No involvement of compiler
2017-11-07T21:16:17.000213
Guillermo
clojurians
clojure
basically, `(comp (map inc) (filter even?) (map inc))` is no better a representation of the process from an apparent point of view than the s-expression `((map inc) (filter even?) (map inc))`, or the s expression `(map inc (filter even? (map inc)))`
2017-11-07T21:16:51.000252
Evelin
clojurians
clojure
the idea of transducers were to separate the definition of what was being done from the thing upon which it was being done
2017-11-07T21:18:08.000040
Evelin
clojurians
clojure
i posit that we could already do this
2017-11-07T21:18:13.000184
Evelin
clojurians
clojure
because this is lisp
2017-11-07T21:18:15.000273
Evelin
clojurians
clojure
neat
2017-11-07T21:18:48.000111
Jonas
clojurians
clojure
the real reason transducers are around is because clojure see's `(map inc (filter even? (map inc x)))` and makes three sequences
2017-11-07T21:18:55.000017
Evelin
clojurians
clojure
it isn't smart enough to know it can unravel for you
2017-11-07T21:19:05.000211
Evelin
clojurians
clojure
I don't really know what you're arguing for tbh
2017-11-07T21:19:08.000129
Guillermo
clojurians
clojure
just for my understanding, how does this compare to `(comp (partition-by consecutive-fn) (map merge-fn))`?
2017-11-07T21:19:27.000201
Jonas
clojurians
clojure
Transducers are independent of collections. They don't compare to a collection pipeline
2017-11-07T21:19:48.000197
Guillermo
clojurians
clojure
But sure, can make a macro that does a lot of things. Transducers as they are in core hit a sweet spot with expressivity and leverage
2017-11-07T21:21:10.000028
Guillermo
clojurians
clojure
The merge-fn is reduced over each partition instead of given a partition as an argument.
2017-11-07T21:21:10.000196
Giovanna
clojurians
clojure
Does that make sense?
2017-11-07T21:21:17.000036
Giovanna
clojurians
clojure
The examples being bandied about (map inc) are nice because they capture only essential detail
2017-11-07T21:21:45.000019
Guillermo
clojurians
clojure
Hard to improve on that
2017-11-07T21:22:05.000094
Guillermo
clojurians
clojure
so more like `(comp (partition-by consecutive-fn) (map #(reduce merge-fn %))`?
2017-11-07T21:22:11.000128
Jonas
clojurians
clojure
I think that would be equivalent. Nice one!
2017-11-07T21:23:23.000226
Giovanna
clojurians
clojure
although, I think your example wouldn’t have to hold a whole partition in memory at the same time
2017-11-07T21:23:47.000149
Jonas
clojurians
clojure
There would have to be a huge benefit to incur additional complexity into the compiler or macro. Not saying that's a no, but it's unlikely to be sufficiently compelling.
2017-11-07T21:24:02.000016
Guillermo
clojurians
clojure
so if you had large partitions
2017-11-07T21:24:03.000108
Jonas
clojurians
clojure
That's true
2017-11-07T21:24:20.000172
Giovanna
clojurians
clojure
Esp to overcome the inertia of adding an opt phase in the compiler
2017-11-07T21:24:42.000164
Guillermo
clojurians
clojure
my biggest gripe is that transducer's inherent value seems to be that you can describe a process to be done on the elements of a data source (channel, collection, sequence, iterable, whatever else) by "composing that process out of transducers"-- but you could already DESCRIBE that process anyway, without resorting to composing functions; you could just compose data in S-expressions that literally represent what you are doing to whatever thing you are doing it to; and if you want it to be independent of the thing you have that choice already! just omit it from the S-expression (its always going to be the most nested, rightmost element)
2017-11-07T21:25:34.000171
Evelin
clojurians
clojure
i’m trying to figure out if the same transducer could be created from two simpler transducers, but my brains a little fried at the moment
2017-11-07T21:25:46.000192
Jonas
clojurians
clojure
too much philosophizing about tranducers :stuck_out_tongue:
2017-11-07T21:25:55.000166
Jonas
clojurians
clojure
so i'm wracking my head trying to think, what do transducers really actually do? They don't necessarily allow me to communicate anything about the process of transformation on data moreso than i could without them, and they don't allow me to separate the process from the thing being processed moreso than i could do without them
2017-11-07T21:26:24.000264
Evelin
clojurians
clojure
i can only think that what transducers really do that the nested S-expressions don't is to capture the idea of doing a bunch of processes together at once in one pass on whatever the thing is
2017-11-07T21:27:22.000057
Evelin
clojurians
clojure
I think you could say that about functions in clojure in general
2017-11-07T21:27:26.000132
Jonas
clojurians
clojure
once you do `(def myfn (fn [x] (+ x 1)))`
2017-11-07T21:27:34.000054
Jonas
clojurians
clojure
you don’t pass around the s-expr
2017-11-07T21:27:44.000184
Jonas
clojurians
clojure
you pass around the function
2017-11-07T21:27:49.000168
Jonas
clojurians
clojure
and you can’t really take it apart later
2017-11-07T21:27:55.000035
Jonas
clojurians
clojure
I find them fun and tiring to write :slightly_smiling_face:
2017-11-07T21:28:51.000113
Giovanna
clojurians
clojure
if you hand somebody `myfn`, they can’t tell if it’s made up for complicated stuff or that it just returns a constant
2017-11-07T21:29:17.000045
Jonas
clojurians
clojure
hehe
2017-11-07T21:29:41.000280
Jonas
clojurians
clojure
that’s kinda why i’m hoping you could make more complicated transducers by just composing simpler ones
2017-11-07T21:30:01.000259
Jonas
clojurians
clojure
because, as you mentioned, there are a bunch of rules that you have to follow
2017-11-07T21:30:33.000244
Jonas
clojurians
clojure
… or else
2017-11-07T21:30:49.000088
Jonas
clojurians
clojure
kaboom
2017-11-07T21:30:52.000125
Jonas
clojurians
clojure
if the idea of transducers was to separate what is being done from the thing is is being done to, isn't that just the definition of a function?
2017-11-07T21:31:36.000104
Evelin
clojurians
clojure
doesn't `myfn` do precisely that?
2017-11-07T21:31:49.000157
Evelin
clojurians
clojure
why should i need transducers when i have `(fn ...)`
2017-11-07T21:32:08.000130
Evelin
clojurians
clojure
i mean, you can take a look at the definitions of the different transducers
2017-11-07T21:32:24.000123
Jonas
clojurians
clojure
and they are “just functions”
2017-11-07T21:32:29.000203
Jonas
clojurians
clojure
I think it’s useful to say more about them and give them a name like transducers
2017-11-07T21:32:43.000247
Jonas
clojurians
clojure
for these types of functions, `map`, `filter`, `dedupe`, etc
2017-11-07T21:33:04.000149
Jonas
clojurians
clojure
and having the tranducers as a separate thing has already paid off
2017-11-07T21:33:29.000048
Jonas
clojurians
clojure
Yes, exactly. I think that you mostly can do that, but sometimes there are just basic building blocks that aren't compositions of other transducers. And sometimes, like I did, you make a new one cause you don't have the imagination to combine two existing ones.
2017-11-07T21:33:43.000185
Giovanna
clojurians
clojure
originally, core async had their own map, filter, dedupe functions
2017-11-07T21:33:45.000111
Jonas
clojurians
clojure
but now you can reuse these core functions in core async or use them with lazy sequences
2017-11-07T21:34:07.000071
Jonas
clojurians
clojure
it seems kinda obvious that it should be possible, but if you look around at other ecosystems, they do have have a `map` for Rx, and then `map` for collections
2017-11-07T21:34:45.000175
Jonas
clojurians
clojure
Take a look at source of the xforms library some time, some of those are basic building blocks. (Fair warning, trying to grok that is headache inducing.)
2017-11-07T21:34:59.000061
Giovanna
clojurians
clojure
i don't mean to imply that i think we should have a bunch of different maps for different data types
2017-11-07T21:35:21.000070
Evelin
clojurians
clojure
i'm trying to say that i don't think we need transducers to avoid that
2017-11-07T21:35:28.000158
Evelin
clojurians
clojure
yea, it seems neat
2017-11-07T21:36:09.000247
Jonas
clojurians
clojure
thanks for the link!
2017-11-07T21:36:17.000160
Jonas