Created
July 20, 2017 16:46
-
-
Save DrBoolean/c255cabc6c0d48bb9c0765a13551ae2a to your computer and use it in GitHub Desktop.
rep5
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
const Pair = (x, y) => | |
({ | |
_0: x, | |
_1: y, | |
map: f => Pair(x, f(y)) | |
}) | |
// to :: Pair a -> (Bool -> a) | |
const to = ({_0, _1}) => | |
bool => bool ? _0 : _1 | |
// from :: (Bool -> a) -> Pair a | |
const from = f => | |
Pair(f(true), f(false)) | |
from(to(Pair(‘hot’, ‘cold’))) // Pair(‘hot’, ‘cold’) | |
to(from(x => !x ? ‘cold’ : ‘hot’)) // bool => bool ? _0 : _1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment