Created
January 26, 2018 13:31
-
-
Save wreczek/b0e3d2f11d2a5a54be214b787907379c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Pairs | |
(first, second,pair) where | |
--needed for first and second operations, uses true and false | |
-- from ChurchBooleans | |
import ChurchBooleans | |
-- functions that are needed for list operations | |
first :: ((t1 -> t2 -> t1) -> t) -> t | |
first = \f -> f(true) | |
second :: ((t1 -> t2 -> t2) -> t) -> t | |
second = \f -> f(false) | |
pair :: t1 -> t2 -> (t1 -> t2 -> t) -> t | |
pair= \x y f -> f(x)(y) | |
-- to_integer(second(pair(one)(two))) returns 2 | |
-- unchurch(second(pair(one)(church(15)))) returns 15 | |
-- unchurch(second(pair(one)(church(15)))) returns 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment