Thanks for your answer, I think it emphasizes that my example matches
the exclaimed conditions
>> * small
>> * useful
>> * demonstrate Haskell's power
>> * preferably something that might be a bit
>> tricky in another language
It's easy to encode this in some object oriented language with generics,
^^^^
[some dozen lines of java]
The haskell solution may be much shorter, but it is far from impossible
to encode such things in a plain-and-boring mainstream language like
java. The promotional value of this (and similar) examples shrinks down
to "haskell code is much shorter". Wich is true, and important, but may
not be enough to consider learning some crazy programming language.
Okay, nobody sayed its impossible. GHC compiles Haskell programs to some
kind of C. But first: Shorter code has less chances for bugs and is
easier to maintain...
More important: Correct me, if I'm wrong, but as far as I understand
java, it is still impossible in your solution to evaluate the equivalent of
head $ mirror $ rel [ (i,i) | i <- [0..] ]
in finite time, that is, your MirrorRel is not lazy in the elements. You
have to build this also by hand and your code becomes even longer and
more complex.
(Java developers who don't understand Java's advanced features like
generics and anonymous classes may not be able to write or understand
the above written Java solution; but do you expect them to understand
Haskell?)
Add 1: This statement contradicts your "easyness" claim!?
Add 2: In contrast, the Haskell solution does'nt uses "advanced Haskell
features" (whatever this might be), it consists of 6 lines of plain
Haskell 98 only.
Regards,
--
-- Mirko Rahn -- Tel +49-721 608 7504 --
--- http://liinwww.ira.uka.de/~rahn/ ---
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe