Lambda over types.
anatoli
anatoli@yahoo.com
Thu, 21 Mar 2002 09:37:46 -0800 (PST)
--0-681966285-1016732266=:42373
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hal Daume III <hdaume@ISI.EDU> wrote:
> I'd be interested in seeing how you do this. I attempted such a thing a
> while back but was unsuccessful.
Attached are two interpreters: one for untyped lambda calculus,
and one for an Unlambda-style language (combinators).
Of course pure lambda terms are not very useful Haskell types.
You may use your own types as primitive terms by defining
instances of Subst and/or Eval of them.
--
anatoli
__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/
--0-681966285-1016732266=:42373
Content-Type: application/x-unknown; name="lambda.lhs"
Content-Transfer-Encoding: base64
Content-Description: lambda.lhs
Content-Disposition: attachment; filename="lambda.lhs"
VGhlIGNsYXNzIG1ldGhvZHMsIGxhbWJkYVN1YnN0IGFuZCBsYW1iZGFFdmFs
LCBhcmUKZm9yIGRlYnVnZ2luZyBmcm9tIEh1Z3MvZ2hjaSBwcm9tcHQuClRv
IGV2YWx1YXRlIGEgdGVybSwgdHlwZToKCkxhbWJkYT46dCBsYW1iZGFFdmFs
IDx0ZXJtPgoKZm9yIGluc3RhbmNlCgpMYW1iZGE+OnQgbGFtYmRhRXZhbCAo
QSAoTCBYIFgpIChMIFkgWikpCkwgWSBaCkxhbWJkYT46dCBsYW1iZGFFdmFs
IChBIChMIFggKEEgWCBYKSkgKEwgWCAoQSBYIFgpKSkKPGRvZXMgbm90IHRl
cm1pbmF0ZT4KCj4gbW9kdWxlIExhbWJkYSB3aGVyZQoKVmFyaWFibGVzIAoK
PiBkYXRhIFggPSBYCj4gZGF0YSBZID0gWQo+IGRhdGEgWiA9IFoKPiBkYXRh
IFQgPSBUCgpMYW1iZGEgYWJzdHJhY3Rpb24gOiBceC0+eQoKPiBkYXRhIEwg
eCB5ID0gTCB4IHkKCkFwcGxpY2F0aW9uIDogeCB5Cgo+IGRhdGEgQSB4IHkg
PSBBIH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C0+IGUnIHdoZXJlCj4gICBsYW1iZGFFdmFsIDo6IGUgLT4gZScKPiAg
IGxhbWJkYUV2YWwgPSB1bmRlZmluZWQKClZhcmlhYmxlcyBldmFsdWF0ZSB0
byB0aGVtc2VsdmVzCgo+IGluc3RhbmNlIEV2YWwgWCBYCj4gaW5zdGFuY2Ug
RXZhbCBZIFkKPiBpbnN0YW5jZSBFdmFsIFogWgo+IGluc3RhbmNlIEV2YWwg
VCBUCgpTbyBpcyBsYW1iZGEgYWJzdHJhY3Rpb24KCj4gaW5zdGFuY2UgRXZh
bCAoTCB2IGUpIChMIHYgZSkKCkFwcGxpY2F0aW9uIG9mIGxhbWJkYSBhYnN0
cmFjdGlvbiBpcyBldmFsdWF0ZWQgdmlhIHN1YnN0aXR1dGlvbgoKPiBpbnN0
YW5jZSAoU3Vic3QgdiBnIGUgciwgRXZhbCByIHInKSA9PiBFdmFsIChBIChM
IHYgZSkgZykgcicKCkFwcGxpY2F0aW9uIG9mIGFwcGxpY2F0aW9uOiBldmFs
dWF0ZSB0aGUgZnVuY3Rpb24gYW5kIHJldHJ5CkhlcmUgbGllcyB0aGUgdW5k
ZWNpZGFiaWxpdHkuCgo+IGluc3RhbmNlIChFdmFsIChBIGIgYykgZCwgRXZh
bCAoQSBkIGUpIGYpID0+IEV2YWwgKEEgKEEgYiBjKSBlKSBmCgo=
--0-681966285-1016732266=:42373
Content-Type: application/x-unknown; name="unlambda.lhs"
Content-Transfer-Encoding: base64
Content-Description: unlambda.lhs
Content-Disposition: attachment; filename="unlambda.lhs"
UXVhc2ktVW5sYW1iZGEgaW50ZXJwcmV0ZXIgaW4gSGFza2VsbCBjbGFzc2Vz
IQpTZWUgbGFtYmRhLmxocyBmb3IgaW5zaWdodC4KCj4gbW9kdWxlIFVubGFt
YmRhIHdoZXJlCgo+IGRhdGEgSyAgICAgICAgPSBLCj4gZGF0YSBLMSB4ICAg
ICA9IEsxIHgKCj4gZGF0YSBTICAgICAgICA9IFMKPiBkYXRhIFM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