[Haskell-cafe] New to Haskell
Benja Fallenstein
benja.fallenstein at gmail.com
Tue Dec 18 05:08:31 EST 2007
Hi Cristian,
On Dec 18, 2007 10:53 AM, Cristian Baboi <cristi at ot.onrc.ro> wrote:
> >> - the lambda expressions can be written (input) but cannot be printed
> >> (output)
>
> > Yes, since two different lambda expressions can denote the same function.
> I just want the sistem to be able to print one of these expressions !
>
> Its this too much to ask ?
> I find it very strange that I can write a lambda expresion, but the system
> cannot.
It's a trade-off. Haskell has as a design goal that you can use
equational reasoning everywhere -- that if you have two ways of
writing the same function, you can substitute one for the other in any
expression, without changing the result of that expression. For
example, since you can prove
sum = foldl (+) 0 = foldr (+) 0 = last . scanl (+) 0
you can, in any place you use 'sum,' substitute any of these
expressions without changing the result.
You couldn't do this if you could write (show sum) and (show $ foldl
(+) 0) and they would return different values.
You could design the language differently, of course, but the Haskell
designers want you -- and the compiler -- to be able to use equational
reasoning everywhere -- so they disallow printing functions.
- Benja
More information about the Haskell-Cafe
mailing list