Skip to content

Instantly share code, notes, and snippets.

@kitasuna
Created March 13, 2019 11:39
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/9ba9702b2ccc35d4b5807f73d7d3673a to your computer and use it in GitHub Desktop.
Save kitasuna/9ba9702b2ccc35d4b5807f73d7d3673a to your computer and use it in GitHub Desktop.
Defining custom functions in sanctuary
const $ = require('sanctuary-def')
const def = $.create({
checkTypes: true,
env: $.env
})
const bangBang =
def ('bangBang')
({})
([$.String, $.String])
(xs => {
return xs
// convert the string to an array of chars
.split('')
// throw away the char and replace it with '!'
.map( _x => '!' )
// put the array back together into a string
.join('')
})
const bangBangBad =
def ('bangBangBad')
({})
([$.String, $.String])
(xs => true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment