Lab4: substitution in Haskell

4 views
Skip to first unread message

Marcus Hedenström

unread,
Mar 8, 2010, 3:45:56 PM3/8/10
to proglang-c...@googlegroups.com
Hi,
We have translated our definitions to lambda abstractions, an are able to look them up from evalExp (Application expression).

f a b c = a + b +c
main = f 1 2 4

Fetch lambda abstraction:
\a -> \b -> \c -> a + b + c


Abstraction type: EAbstraction Exp Exp
substitute :: Exp -> Value -> Exp
substitute abstraction value = ??????????

How would we know (or the interpreter, rather) which variables among all variables in the lambda abstraction are to be replaced?


Thanks!
- Marcus

Arnar Birgisson

unread,
Mar 8, 2010, 4:01:24 PM3/8/10
to proglang-c...@googlegroups.com
Hi,

On Mon, Mar 8, 2010 at 21:45, Marcus Hedenström
<marcus.h...@gmail.com> wrote:
> Abstraction type: EAbstraction Exp Exp
> substitute :: Exp -> Value -> Exp
> substitute abstraction value = ??????????
>
> How would we know (or the interpreter, rather) which variables among all variables in the lambda abstraction are to be replaced?

First of all you should reconsider your EAbstraction grammar rule.
Does it really make sense for the first part to be an arbitrary
expression? E.g. is \(x+y) -> y a valid abstraction?

Having fixed that, I think the answer to your original question will
become clear. :)

cheers,
Arnar

Reply all
Reply to author
Forward
0 new messages