[Haskell-cafe] Bound and free variables

Kyle Marek-Spartz kyle.marek.spartz at gmail.com
Tue Sep 23 13:10:12 UTC 2014


Additionally, since let is “let rec”, it can’t be translated into a lambda expression using that method in all cases, e.g.  

let f x = g x  
  g x = 1
in f 2

==>  

(\f -> (\g -> f 2)) (\x -> g x) (\x -> 1)  

In the lambda expression, the second g is free, whereas the corresponding g in Haskell is bound.  

–  
Kyle Marek-Spartz
  
  
  
  
  
On Sep 23, 2014, 8:01:29 AM, Barak A. Pearlmutter <barak at cs.nuim.ie> wrote:  

On Mon, 22 Sep 2014 19:30:33 -0400, Michael Orlitzky wrote:

> It's hard to tell from your example, but if you want, you can
> translate the let binding directly to lambda calculus and then go from
> there where the rules are simple.
>
> In Haskell,
>
> let = in
>
> translates to,
>
> ( -> )

Although this list might not be for homework problems, there is an
element of terminological confusion and a quest for nomenclature in the
question that don't seem entirely unreasonable. Even if we're not going
to answer the question per se, we shouldn't give hints that are
misleading, or true in Scheme and lambda calculus but false in Haskell.

$ ghci

Prelude> let b = 3:b in take 3 b
[3,3,3]

Prelude> ( -> take 3 b) (3:b)
:3:21: Not in scope: `b'
_______________________________________________
Haskell-Cafe mailing list
mailto:Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140923/4e90c6e0/attachment.html>


More information about the Haskell-Cafe mailing list