What Does Haskell Have to Do with C++?
bartoszmilewski.wordpress.com
bartoszmilewski.wordpress.com
Also it is interesting to note, that both Haskell and C++ world is full of discussions about how to do something remarkably complex to get nice syntax for something. You don't see that in lisp world, where such problems are simply solved by macros and nobody goes into great lengths to (ab)use some random language feature to get nice syntax for his library.
Nice compiler error messages are the real thing now.
Seriously: I feel the need to express something in a concise and somewhat beautiful way to be a large part of C++ culture and partly a reason for so many people shying away from less expressive languages. Some of the Boost libraries are even centered around the whole idea and required a lot of effort (see Boost::assign).
This statement suggests the author has limited exposure to Common Lisp, which supports the widest variety of programming paradigms in one language that I can think of. Simplicity of syntax seems to be mostly orthogonal to allowing the use of many paradigms, though it's probably hard to have a very complex syntax with a semantically simple language.
Perl Cannot Be Parsed: A Formal Proof
And in the TeX case it also depends on what you expect as output of parsing, if you want some meaningful AST, it is even more complex (and probably impossible). Because even if you would remove the ability to redefine character categories, you would still be able to only get stream of tokens without clear semantic meaning.
But whole this discussion is mostly theoretical, because for reasonable inputs (like LaTeX), parser can effectively guess. Also, in CL cases many of these problems are solved by various conventions (like having most of relevant state consistent for whole file and specified in comment that is readable by said tools).
Allow me to introduce you to Mozart/Oz and AliceML. Seriously, those two twin languages are the most epic out there.
You would have to hack CL extensively, and bundle various libraries to make it on par with Oz or Alice. Maybe CL + Screamer + FSet + Heresy + pcall + cl-store would be a pale, distant imitation.
For the last 50 years, PL research has been done with minimal kernel languages, implementing few features. Don't know what mental mutation caused the Oz team to go the opposite way and implement "everything imaginable" in a tiny language, but I like it. The core of Oz is no larger than Scheme, btw.
Having said that, I've never actually used it for anything substantial.
I have "ported" my knowledge to Common Lisp and use it there; but I have been actively re-learning ML for the past few months.
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!