Code Monkey home page Code Monkey logo

Comments (12)

Avaq avatar Avaq commented on June 12, 2024 1

These functions are not meant to be user-facing. Instead they exist as part of an interface for dispatcher functions which the end user can use. These dispatchers can be made curried, and usually are (look at Ramda or Sanctuary).

Having them as uncurried in the underlying interface is beneficial for performance, and doesn't hurt the end user, who will use dispatcher functions to interact with conformant values.

from fantasy-land.

davidchambers avatar davidchambers commented on June 12, 2024 1

The specification exists to provide “interoperability of common algebraic structures in JavaScript”. Breaking changes break interoperability; we would need a very compelling reason to consider a breaking change.

I share your belief that composition is important. Note, though, that the Fantasy Land specification was created to foster interoperability, not composition. The specification promotes lawful abstractions, not a particular style of programming.

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024 1

What about open-close principle? Just extend your spec.

from fantasy-land.

bergus avatar bergus commented on June 12, 2024 1

Тhe comma looks like a new syntax element in the context of FP.

The comma is not a new syntax element in the context of JavaScript, which this specification is all about. "FP" does not have a syntax. If you want to design your own language that doesn't use commas, so be it, but it's no longer JavaScript; at best it's a subset with arbitrary restrictions.

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024 1

@davidchambers , yes, that's exactly what i'm talking about

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024

It turns out that Ramda is doing your job, and you are doing theirs. The task of the specification is to provide the correct abstraction, and the developers' task is to provide the correct implementation in terms of performance.
The function should not have more than one argument, otherwise you will not be able to use it in composition, but create your own crutches

from fantasy-land.

davidchambers avatar davidchambers commented on June 12, 2024

The function should not have more than one argument, otherwise you will not be able to use it in composition

The methods in question are not intended to be invoked by users directly. As Aldwin stated, functions wrapping these methods are usually curried. S.traverse and S.reduce are two such functions.

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024

The function should not have more than one argument, otherwise you will not be able to use it in composition

The methods in question are not intended to be invoked by users directly. As Aldwin stated, functions wrapping these methods are usually curried. S.traverse and S.reduce are two such functions.

I just want to say that currying these functions should be at the specification level. Otherwise, we ourselves create problems with the composition, and then we proudly solve them.

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024

Тhe comma looks like a new syntax element in the context of FP.

The comma is not a new syntax element in the context of JavaScript

Am I talking about javascript?
Speech about the specification. First, FP introduces currying to get rid of the multiplicity of arguments, and then it itself returns to this multiplicity.

from fantasy-land.

CrossEye avatar CrossEye commented on June 12, 2024

@Ne4to777:

One of the major design constraints for this specification was that it is meant to work as closely as possible to existing Javascript tools. There are reasons the functions are called, for instance, map and reduce rather than fmap and foldl. This makes integration with standard JS built-in types as seamless as possible. But Foldable's reduce won't work with arrays if we change the signature of the callback.

When FantasyLand moved to namespaced functions, the specification could have made a different call, since there was no direct link between a ['reduce'] and a ['fantasy-land/reduce']. But that would have precluded the easy aliasing path to upgrade that many libraries used then and probably still use.

As David Chambers pointed out above, this specification is all about interoperability. It is not a prescriptive treatise on how to write FP code.

from fantasy-land.

Ne4to777 avatar Ne4to777 commented on June 12, 2024

@CrossEye ,
Which JS tools are trying to approach traversable?
How naming interferes with FP?
If we have already created own namespace for reduce, why don't we make it curried?

from fantasy-land.

davidchambers avatar davidchambers commented on June 12, 2024

If we have already created own namespace for reduce, why don't we make it curried?

There is no need to do so. The function you desire can already be defined:

> S.reduce
reduce :: Foldable f => (b -> a -> b) -> b -> f a -> b

> S.reduce (xs => x => [x, ...xs]) ([]) ([1, 2, 3, 4, 5])
[5, 4, 3, 2, 1]

> S.reduce (s => t => s + t) ('foo') (S.Just ('bar'))
'foobar'

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.