Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add outline of Church option type #11

Merged
merged 1 commit into from
Dec 10, 2017
Merged

Conversation

billpmurphy
Copy link
Contributor

Simple implementation of an option type encoded as functions. Feel free to reject if you believe this doesn't fit in with the rest of what's in the church module.

I didn't add anything to impl Term, I'm not sure what (if anything) should be added there for options.

@ljedrz
Copy link
Owner

ljedrz commented Dec 10, 2017

I'm all for adding other Church data types (especially when they are as useful as Option<T>), but I always try to provide some reference backing them, at least in the module's documentation; could you provide one?

@billpmurphy
Copy link
Contributor Author

This took me down a fun research rabbit hole.

The Wikipedia article on Church encoding mentions "tagged unions" but doesn't elaborate. There are few papers (e.g. 1, 2, 3) that mention the Church encoding of algebraic data types as "more common" than Morgensen-Scott encoding or Boehm-Berarducci encoding but don't provide a reference. The Wikipedia article on Morgensen-Scott encoding mentions this but also lacks a reference.

This is the earliest paper I could find that describes how to Church-encode arbitrary algebraic data types. There also are a bunch of blog posts (e.g. 1, 2, 3, 4) that demonstrate the same concept as well with Option/Maybe as an example.

Since there's no drop-in Wikipedia reference, do you have a preference for what to cite?

@ljedrz ljedrz merged commit d6b4e07 into ljedrz:master Dec 10, 2017
@ljedrz
Copy link
Owner

ljedrz commented Dec 10, 2017

Hmm, there's no clear winner, but I guess we could leave it for later. There are some minor details in this commit that I'd like to adjust when I have time, but overall I think this is a very nice addition to the Church collection.

@billpmurphy billpmurphy deleted the option branch December 10, 2017 23:46
@ljedrz
Copy link
Owner

ljedrz commented Dec 11, 2017

As for adding related impl Term methods I'm not sure myself; on one hand, there are some of them available for Church lists, numerals and pairs and they are much faster than their Church equivalents; on the other, they aren't the core functionality of this library and most users probably aren't concerned with the performance. They may even be dropped altogether in version 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants