Created
March 13, 2019 11:39
-
-
Save kitasuna/9ba9702b2ccc35d4b5807f73d7d3673a to your computer and use it in GitHub Desktop.
Defining custom functions 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 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