by DannoHung · 16y ago · 0 comments
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++.
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.I don't know if it's as good as writing some neat functional code, but for me it's still fun!