Nullary types in Sanctuary
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 $ = require('sanctuary-def') | |
const { create, env } = require('sanctuary') | |
const def = $.create({ | |
checkTypes: true, | |
env: $.env | |
}) | |
const MyBool = $.NullaryType | |
('dokidoki-types/MyBool') | |
('http://dokidokidriven.com/types/MyBool') | |
([]) | |
((x) => x === 'T' || x === 'F') | |
const S = create({checkTypes: true, env: env.concat ([MyBool])}) | |
const _myAnd = | |
def ('myAnd') | |
({}) | |
([MyBool, MyBool, MyBool]) | |
const _myOr = | |
def ('myOr') | |
({}) | |
([MyBool, MyBool, MyBool]) | |
const _myNot = | |
def ('myNot') | |
({}) | |
([MyBool, MyBool]) | |
const myAnd = _myAnd | |
( a => b => { | |
return a === 'T' && b === 'T' ? 'T' : 'F' | |
}) | |
const myOr = _myOr | |
( a => b => { | |
return a === 'T' || b === 'T' ? 'T' : 'F' | |
}) | |
const myNot = _myNot | |
( a => { | |
return a === 'T' ? 'F' : 'T' | |
}) |
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
{ | |
"name": "nullary-types", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"sanctuary": "^2.0.0", | |
"sanctuary-def": "^0.20.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment