Skip to content

Instantly share code, notes, and snippets.

@kitasuna kitasuna/index.js
Created Sep 7, 2019

Embed
What would you like to do?
Nullary types in Sanctuary
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'
})
{
"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
You can’t perform that action at this time.