Lambda over types.
anatoli
anatoli@yahoo.com
Thu, 4 Apr 2002 02:29:43 -0800 (PST)
--0-2060797451-1017916183=:35143
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
(Redirected from haskell to haskell-cafe.)
Well, I tried to fix the problems you mention.
Results attached. I have managed to do without de Brujin
notation. The evaluator is (modulo bugs!) normal order.
One can easily do an applicative order evaluator as well.
Evaluating to WHNF is probably easy too (this is what the
previous version supposed to do).
I'll try to come up with a regression test suite for this
stuff as my (copious :) free time permits, but on the surface it
looks ok.
--- oleg@pobox.com wrote:
>
>
> anatoli <anatoli at yahoo> wrote:
>
> > This is all, of course, of purely academical interest. The notation
> > is extremely inconvenient to do any real work. I'd rather prefer
> > a real, language-supported lambda over types.
>
> > Or... wait a minute! You did find all those problems; does it mean
> > you tried to *use* this stuff for something? Just curious.
>
> I must start with a profuse apology, because what follows is perhaps
> of little relevance to the list. I also propose to re-direct the
> follow-ups to the Haskell Cafe.
>
> I have examined your code and then tried a few examples, some of which
> from my code's regression tests.
>
> I have implemented a compile-time lambda-calculator, in a different
> language. I should say, in a meta-language. The output of the
> evaluator is a term that can then be compiled and evaluated. The
> lambda-calculator acts as a partial evaluator. The calculator
> normalizes a term in a pure untyped lambda calculus. The result is
> compiled and evaluated in a call-by-value lambda-calculus with
> constants.
>
> Haskell typechecker (augmented with multi-parameter classes with
> functional dependencies and let on loose) may do something similar.
>
> BTW, the meta-language lambda-evaluator code (with the regression tests)
> can be found at
> http://pobox.com/~oleg/ftp/Computation/rewriting-rule-lambda.txt
> The calculator is implemented in CPS, in some sort of extended lambda
> calculus. Therefore, the code has three kinds of lambdas: of the source
> language, of the transformer meta-language, and of the target
> language. The first and the third lambdas are spelled the same and
> are the same.
>
>
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
--0-2060797451-1017916183=:35143
Content-Type: application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