Last active
April 30, 2018 20:05
-
-
Save kylecorbelli/f703932d7d1fa33b2879af57f8e74d27 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { compose, toUpper } from 'ramda' | |
function unsafeHead<T> (list: ReadonlyArray<T>): T { | |
return list[0] | |
} | |
type UpperCaseHead = (list: ReadonlyArray<string>) => string | |
const upperCaseHead: UpperCaseHead = compose( | |
toUpper, | |
unsafeHead, | |
) as UpperCaseHead | |
upperCaseHead([]) // ruh-roh: | |
// /Users/kcorbelli/Documents/practice-scripts/typescript/maybe/node_modules/ramda/src/invoker.js:44 | |
// throw new TypeError(toString(target) + ' does not have a method named "' + method + '"'); | |
// ^ | |
// TypeError: undefined does not have a method named "toUpperCase" | |
// at /Users/kcorbelli/Documents/practice-scripts/typescript/maybe/node_modules/ramda/src/invoker.js:44:11 | |
// at f1 (/Users/kcorbelli/Documents/practice-scripts/typescript/maybe/node_modules/ramda/src/internal/_curry1.js:18:17) | |
// at /Users/kcorbelli/Documents/practice-scripts/typescript/maybe/node_modules/ramda/src/internal/_pipe.js:3:14 | |
// at /Users/kcorbelli/Documents/practice-scripts/typescript/maybe/node_modules/ramda/src/internal/_arity.js:10:19 | |
// at Object.<anonymous> (/Users/kcorbelli/Documents/practice-scripts/typescript/maybe/maybe.js:86:13) | |
// at Module._compile (module.js:573:30) | |
// at Object.Module._extensions..js (module.js:584:10) | |
// at Module.load (module.js:507:32) | |
// at tryModuleLoad (module.js:470:12) | |
// at Function.Module._load (module.js:462:3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment