我有一个小的代码示例,在使用 ramda 时可以按预期工作,但是我尝试将其移植到 sanctuary 失败了。
const IO = require('fantasy-io');
const S = require('sanctuary');
const R = require('ramda');
const url = 'http://localhost:8010?param1=arg1¶m2=arg2';
const io = IO.of(url);
// Works as expected:
const r = R.map(R.split('?'), io);
console.dir(r.unsafePerform());
// -> [ 'http://localhost:8010', 'param1=arg1¶m2=arg2' ]
// Fails:
const s = S.map (S.splitOn('?')) (io);
console.dir(s.unsafePerform());
问题是 ramda 版本按预期工作,但 sanctuary 版本退出并出现此错误,有人可以解释原因。
TypeError: Invalid value
splitOn :: String -> String -> Array String
^^^^^^
1) function() {
return x;
} :: Function, (a -> b)
The value at position 1 is not a member of ‘String’.