[Haskell-beginners] Fwd: Here's why functions should return functions
Antoine Latter
aslatter at gmail.com
Sun Jul 29 20:04:12 CEST 2012
Oops, I forgot to "reply-all"
---------- Forwarded message ----------
From: Antoine Latter <aslatter at gmail.com>
Date: Sun, Jul 29, 2012 at 1:03 PM
Subject: Re: [Haskell-beginners] Here's why functions should return functions
To: Jay Sulzberger <jays at panix.com>
On Sun, Jul 29, 2012 at 12:00 PM, Jay Sulzberger <jays at panix.com> wrote:
>
>
> There is, in most sub-systems of mathematics, whether like recent
> type theory or not, a general function, let us call it mcf which
> in Scheme notation may be defined by executing
>
> (define mcf
> (lambda (a)
> (lambda (x) a)))
>
> Now in Haskell I know that one, perhaps the, parallel definition
> must result in a polymorphic function.
>
> What is this definition? How polymorphic is it? What implicit
> constraints are on a? Does "lazy vs eager" come in here? Are
> there options to ghc which might modify how Haskell handles the
> definition?
>
I think this is it:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:const
It's definitions is:
const x _ = x
Antoine
> Of course, my questions are too many and I hope just for some
> indications of the first things a beginner should study.
>
> oo--JS.
>
>
> PS. Below is a short Scheme session showing some of the behavior of Scheme.
>
> SCM version 5d9, Copyright (C) 1990-2002 Free Software Foundation.
> SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
> This is free software, and you are welcome to redistribute it
> under certain conditions; type `(terms)' for details.
> ;loading /usr/local/lib/slib/require
> ;done loading /usr/local/lib/slib/require.scm
>>
>> (define mcf
>
> (lambda (a)
> (lambda (x) a)))
> #<unspecified>
>>
>> (define const-17 (mcf 17))
>
> #<unspecified>
>>
>> (const-17 "abc")
>
> 17
>>
>> (define const-1+ (mcf 1+))
>
> #<unspecified>
>>
>> (const-1+ "abc")
>
> #<CLOSURE <anon> "/usr/local/lib/scm/Init5d9.scm": (n) (+ n 1)>
>>
>> ((const-1+ "abc") 200)
>
> 201
>>
>> ((const-1+ 56) 200)
>
> 201
>>
>> (quit)
>
> ;EXIT
>
> Process scheme finished
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list