Skip to content
This repository was archived by the owner on Jul 25, 2018. It is now read-only.
This repository was archived by the owner on Jul 25, 2018. It is now read-only.

Fantasy-IO does not comply to Fantasyland specs #2

@nadameu

Description

@nadameu

According to the Fantasyland spec, v.ap(u.ap(a.map(f => g => x => f(g(x))))) must be equivalent to v.ap(u).ap(a) https://github.com/fantasyland/fantasy-land#apply .

I am using fantasy-io.js and trying to run the following tests:

const log = msg => x => {
  console.log(msg, x);
  return x;
};

const v = IO.of('v');
const u = IO.of(x => `u(${x})`);
const a = IO.of(x => `a(${x})`);

const testA = v.ap(u.ap(a.map(f => g => x => f(g(x)))))
  .map(log('testA = '))
  .unsafePerform();

const testB = v.ap(u).ap(a)
  .map(log('testB = '))
  .unsafePerform();

The result is:
TypeError: f is not a function on the line that says const testA = v.ap(u.ap(a.map(f => g => x => f(g(x)))))

When I swap a and this in the body of the function IO.prototype.ap, the tests succeed:

testA =  a(u(v))
testB =  a(u(v))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions