sanctuary

Mapping with sanctuary over fantasy-land IO


I have a small code sample that works as I expected it to when using ramda, but my attempt to port this to sanctuary has failed.

const IO = require('fantasy-io');
const S = require('sanctuary');
const R = require('ramda');

const url = 'http://localhost:8010?param1=arg1&param2=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&param2=arg2' ]

// Fails:    

const s = S.map (S.splitOn('?')) (io);
console.dir(s.unsafePerform());

The problem is that the ramda version works as expected but sanctuary version exits with this error, can somebody explain the cause of this.

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’.

Solution

  • Only a single version of fantasy-io was ever published:

    $ npm view fantasy-io versions --json
    [
      "0.0.1"
    ]
    

    It targets a very old version of Fantasy Land, so does not support prefixed method names.

    The project has been abandoned. I suggest looking for an alternative. I recommend Fluture, which is mature and well-maintained. It also works nicely with Sanctuary.