"cost free abstractions" just means excessive monomorphization send toot

Follow

rust's iterators are really cool dont get me wrong, but theyre basically a way to trick the optimizing compiler into performing stream-deforesting sheerly thru the power of inlining and monomorphization.

this would be fine if it didnt leak into the type system in confusing ways, like now we're stuck with `impl Iterator`s and super long type definitions if you try to make an associated type an iterator, which are really weird and make it very hard to determine what the performance characteristics of your iterators really are, and just how much code rustc is going to hand to LLVM

@cyberia
its where you take a bunch of chained stream operations (map, filter, flatMap) and squish it into a single pass

@venko
@cyberia
yeah hmm on doing more research i think fusion is a more popular term now and deforestation was some term wadler made up for a single paper, i should probably have said fusion to avoid being confusing

@iitalics well, that seems fine to me. but I haven't ever tried to make an associated type an Iterator in the first place, which I guess is your point.

@iitalics hey wanna see some i think related shit
there's a c++ coroutines talk somewhere from back when the coro TS was very new where one of the guys demonstrates LLVM fucking completely inlining a coroutine loop and i think it's the same thing :blobcat:

@iitalics Yeah agreed with some of those downsides. The nice thing about it being in the types though is that you know when things will fuse or not. I don't really get this in Haskell's fusion rewrite rules for instance - fusion silently breaks on you without giving any type errors to let you know, requiring inspection tests to be sure. Do you know of any alternative ways of doing fusion that address this issue?

Sign in to participate in the conversation
Cybrespace

Cybrespace is an instance of Mastodon, a social network based on open web protocols and free, open-source software. It is decentralized like e-mail.