[Haskell-cafe] On the verge of ... giving up!
Andrew Coppin
andrewcoppin at btinternet.com
Sun Oct 14 10:24:17 EDT 2007
Vimal wrote:
> @Andrew:
>
> But, being a computer science student, I think I need to look into it too!
> I like the quote found on this site: http://patryshev.com/monad/m-intro.html
> <quote>
> Monads in programming seem to be the most mysterious notion of the century.
> I find two reasons for this:
>
> * lack of familiarity with category theory;
> * many authors carefully bypass any mention of categories.
>
> It's like talking about electricity without using calculus.
> Good enough to replace a fuse, not good enough to design an amplifier.
> </quote>
>
Maybe *this* is why I get nowhere with designing electronic things? I
know very little about calculus. (And I can't begin to imagine what it
has to do with electricity...)
For what it's worth, a "category" is a "class" bearing some additional
structure. A "class" is exactly like a "set", except that all sets are
classes, but only some classes are also sets. There *is* a reason for
this, but nobody knows what it is. (They say it's because some classes
are "bigger" than sets - which is absurd since a set can be of any size...)
> Ah, I am not familiar with the "term-rewrite" you are talking about.
> I will Google it up then.
> Thanks :)
>
A term-rewrite system is just a system that replaces ("rewrites")
certain terms with other terms. For example, a package like Mathematica
would have a term rewrite rule that says that all occurrances of "x - x"
should be rewritten as "0". Haskell can't do anything quite *that*
sophisticated, but what it *can* do is things like
linear a b x = a*x + b
which causes all terms involving "linear" to be rewritten into the thing
on the RHS. You can actually draw the "reduction" sequence as an
expression is transformed step by step into the final result:
sum [1,2,3]
foldr1 (+) [1,2,3]
foldr (+) 1 [2,3]
foldr (+) (1+2) [3]
foldr (+) (1+2+3) []
1+2+3
3+3
6
Each line is derrived from the previous one by some program rule. (The
last three being hard-coded into the language itself.)
If you're pathologically curiose, look up "lambda calculus" for a
programming language like Haskell where the last few steps above are
*definable* from first principles. >:-D
More information about the Haskell-Cafe
mailing list