Should folds in containers package remain INLINE

Simon Peyton-Jones simonpj at microsoft.com
Fri May 4 11:01:57 CEST 2012


| I know one thing I run into a lot, especially with folds but also with
| other generic functions, is that what I really want is type class
| specialization. That is, at compile time inline the function enough to
| make the type class parameters static so that the methods can be inlined
| back into the generic function; and then at runtime do type-based
| dispatch to the specialized versions just like if you were looking up
| the instance record or doing SPECIALIZE lookup. The goal being to remove
| the indirect calls in inner loops, but in a particularly restricted way
| since instances are known at compile time and therefore code bloat will
| be limited (unlike, say, function or record arguments).

Can you give a concrete example.  It's hard to be certain but what you describe sounds like exactly what INLINABLE does.

Simon




More information about the Libraries mailing list