Skip to content

Instantly share code, notes, and snippets.

@kitasuna
Created September 7, 2019 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitasuna/c50413b2ed0cc5eadc258a69cef16da6 to your computer and use it in GitHub Desktop.
Save kitasuna/c50413b2ed0cc5eadc258a69cef16da6 to your computer and use it in GitHub Desktop.
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