News for hackers. Stuff that matters.
Re:What Does Haskell Have to Do with C++? by DannoHung on Thursday November 25, 2010 @01:34PM (#1940768)
This is why I hate C++

    template<template<class> class f1, template<class> class f2> struct or_combinator
Incidentally, his or_combinator example is more simply expressed thusly:

    or_combinator f1 f2 x = (f1 x) || (f2 x)
This has the same type signature. Anonymous functions are more useful in Haskell when you have some lexical context which needs to be captured and passed around. If partial application suffices, simply use partial application.

I suppose he was trying to demonstrate that the evaluation does not occur until the value is applied though, if the audience was more familiar with C++.

Re:What Does Haskell Have to Do with C++? by eru on Thursday November 25, 2010 @05:53PM (#1941177)
Or even simpler

  or_combinator = liftM2 (||)
but that requires Haskell knowledge to understand. So you might see it in production code, but your version is the right one for the blog. And the original author's version may be even better for comprehension by C++ programmers.
Re:What Does Haskell Have to Do with C++? by andymorris on Thursday November 25, 2010 @11:17PM (#1941621)
When you get templates working, it does feel pretty good - you can get an approximation of the power of functional languages, all the while knowing that your code has been directly mapped to assembly.

I don't know if it's as good as writing some neat functional code, but for me it's still fun!

Re:What Does Haskell Have to Do with C++? by eru on Friday November 26, 2010 @04:17PM (#1943339)
If you get a decent Haskell compiler working, say ghc, you get the same warm-fuzzy assembly-feeling.