3 ms·
> a lot of benefit in the composition of pure functions, e.g. `take 10 . sort` At the risk of catching HN's ire... this is not a good thing. Haskell's type si
by Veedrac 7y ago
> a lot of benefit in the composition of pure functions, e.g. `take 10 . sort`
At the risk of catching HN's ire... this is not a good thing.
Haskell's type signature tells you almost nothing about whether this use-case is supported. If it's not, you've got yourself a nonlinear slowdown, potentially wrecking your performance. Readers can't know this without literally reading the documentation, except the documentation doesn't even tell you if this is OK.
Yet because people are being ‘clever’ like this, Haskell has ended up stuck with a sort a factor ~ten slower than Python (!!), and an incremental sort that's still a factor ~2 slower than Python's heapq-based incremental sort.
So you're using a sort in a way that you have no explicit language-level guarantees for, seemingly no documented guarantees for at all, and in a way that's incredibly harmful to the common case, but also—and this is a curse that's almost unique to Haskell—the language is also prevented from utilizing future improvements to sorting algorithms!
Because of this, and despite Haskell's ‘purity’, the internals of Haskell's sort are more observable and less open to change than is the case for almost any other language that I know of!
- joel_ms 7y ago>this is a curse that's almost unique to Haskell—the language is also prevented from utilizing future improvements to sorting algorithms! Back in reality of course, Haskell has fast, generic, linear-time sorting: https://hackage.haskell.org/package/discrimination https://hackage.haskell.org/package/discrimination
- Veedrac 7y agoI've been a proponent of radix sort since long before I'd heard of this package, but I think you've completely missed my point.
- tome 7y agoIndeed. It's bizarre that some Haskellers push this as an example of one of the benefits of Haskell when it's implicit behaviour, exactly what I use Haskell to avoid. If, on the other hand, sort were `[a] -> Stream (Of a) ()`, well, that would be something else ...