|
Re: "Green Card" for untyped lambda calculus?: msg#00091lang.haskell.general
Tue, 28 Nov 2000 19:17:32 +0100 (CET), Elke Kasimir <elke.kasimir@xxxxxxxxxx> pisze: > The implementation I'm interested in (one without constructors) is: > > nil fornil forcons = fornil > cons x xs fornil forcons = forcons x xs > forlist fornil forcons ls = ls fornil forcons It can be implemented in extended Haskell with local universal quantification (ghc -fglasgow-exts, hugs -98): newtype List a = List (forall b. b -> (a -> List a -> b) -> b) nil = List (\fornil forcons -> fornil) cons x xs = List (\fornil forcons -> forcons x xs) forlist fornil forcons (List ls) = ls fornil forcons map f = forlist nil (\x xs -> cons (f x) (map f xs)) In ghc algebraic types are really implemented in a similar way :-) Pattern matching jumps into the value, giving to it an array of continuations for each constructor. The value evaluates itself and enters the chosen continuation. It should be also directly implentable in OCaml with -rectypes flag which turns off occurs check for types. -- __("< Marcin Kowalczyk * qrczak@xxxxxxxxxx http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | WoLLIC'2001 - Call for Papers: 00091, Ruy de Queiroz |
|---|---|
| Next by Date: | RE: "Green Card" for untyped lambda calculus?: 00091, Mark P Jones |
| Previous by Thread: | "Green Card" for untyped lambda calculus?i: 00091, Elke Kasimir |
| Next by Thread: | Re: Church' List constructors (was: "Green Card" ...): 00091, Koen Claessen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |