Code Monkey home page Code Monkey logo

Comments (4)

Avaq avatar Avaq commented on June 12, 2024

In my personal (contested) view it does, but not as explicitly. The dependency is captured in the Derivations section of the spec, where a relationship between ap and chain is described:

fantasy-land/ap may be derived from fantasy-land/chain:

function ap(m) { return m['fantasy-land/chain'](f => this['fantasy-land/map'](f)); }

I read this as: "A Chain must implement chain such that ap may be derived from it, and therefore every Chain has ap (is an extension of Apply), and ap must behave as if derived from chain".

EDIT: Another way to think of it is that the Apply interface is like a weaker Chain interface: Apply can be defined in terms of Chain, but not the other way around. Since Apply is a weak Chain, Chain is an extended Apply. So we have the arrow Apply -> Chain come out naturally.

from fantasy-land.

bunglegrind avatar bunglegrind commented on June 12, 2024

Well, the derivation section uses the "may" expression, not the "must". IMHO, an explicit property should be added to the fantasy-land/chain method, which should enfasize the relationship between fantasy-land/ap and fantasy-land/chain (and, possibly, fantasy-land/map). Otherwise, Chain should be placed at the same level of Functor

from fantasy-land.

Avaq avatar Avaq commented on June 12, 2024

I agree with you. I think the "may"-expression in the derivations section is a source of confusion. It's using "may" to suggest that a developer doesn't have to derive their implementation of ap from their implementation of chain, but "may" choose do so.

The reason they "may" choose to do so, is because it is assumed (but never explicitly stated) that this is always possible. I think the spec should be updated to make this more clear.

Furthermore, it is never made clear whether the non-derived implementation of ap must behave in exactly the same way as the version derived from chain would have, but in my view it should. This is the view that's contested (as far as I know, also in the broader FP community).


I've seen this discussion play out in other threads on this repo as well. A quick search came up with #214 but I think there might be more.

from fantasy-land.

bunglegrind avatar bunglegrind commented on June 12, 2024

I see. If I look through all the definitions I find other examples (traversable, for instance). Anyway, I'll follow your suggestion: I'll consider the derivation section mandatory. Thanks!

from fantasy-land.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.