Code Monkey home page Code Monkey logo

Comments (7)

blueberry avatar blueberry commented on September 17, 2024

Hi Alex. Thank you for taking time to write a detailed comment.

I think there is a flaw in your proof. If I understood correctly, you put it as:

  1. Suppose that a and b are true.
  2. Applying some rules, we get c, which is inconsistent.
  3. Therefore, there is unexpected behavior in sequential collections.

I must admit that I don't think that 3 follows from 1 and 2. Actually, the strategy in your proof is one of most common proving strategies in mathematics (as far as I remember), but I would say that the real conclusion should be: a or b (or both) is not true. And, indeed, a and b are not.

So, your proof demonstrated that:

  1. fapply is not equivalent to (fmap apply) (note: partial is not needed here, fmap supports currying). Nor Fluokitten claims it is. I think that Haskell even does not have a lisp-style apply function.
  2. (pure x) is not equivalent to (fmap #(identity)).
    Your code is broken, since Fluokitten pure needs to know the type of the context. So, for collections it should be something like (pure [] x). Also, (fmap #(identity)) is equivalent to (fmap identity), which is clearly not equivalent to pure, since (fmap identity) creates a function that just returns the unchanged input, and (pure [] x) should return [x].

from fluokitten.

adavydow avatar adavydow commented on September 17, 2024

Thank you for your response, however you completely missed my point.

  1. Your library claims to represent some categorical theory structures as protocols. My proof in (1) has nothing to do with your realisation of fapply, the only thing I tried to proof is that your Functor protocol implies Applicative functor structure on objects in hand, not Functor structure. (Functor structure alone is not enough to implement variadic fmap).
    In fact you can translate categorical definitions of Functor and Applicative Functor to programmers' language like this:
    Functor is anything you can non-variadic fmap (non-variadic fmap takes a function of 1 parameter and a functor).
    Applicative Functor is anything you can variadic fmap (variadic fmap takes a function of x >= 0 parameters and x functors).
  2. I mentioned, that there is no way to implement (pure x) as (fmap #(identity x)) in clojure (my phrase about absence of return-type polymorphism and your phrase about need of context is in fact the same). However the claim you tried to object (which is not my claim) that (pure x) = (fmap #(identity)) is absurd and i completely agree that it makes no sence. To make my reasonings about pure clearer I can suggest the following implementation which is completely valid for clojure:
    (pure [x] [y]
    (fmap (fn [z] (identity x)) y)). Usage: (pure 3 [4]) = [3]. (y is for context only))
  3. So both of your protocols implies structures which are isomorphic (an idea of isomorphism is described above). This structure is called "Applivative Functor" in category theory. However
    for sequentional collections there are several ways to provide Applicative Functor structure, and your interfaces provides two different structures.
  4. I'm not going to tell you what applicative functor structure (i) or (ii) you shall prefer for sequential collections, but if you choose one it's better to be consistent and stick with it.
    So, if (fapply [inc dec] [1 2]) = [1 0 1 3] (ii)
    then it'll be greate if (fapply [+] [1 2] [3 4]) = [3 5 5 6] and (fmap + [1 2] [3 4]) = [3 5 5 6]
  5. In category theory every Monad is Applicative Functor and every Applicative Functor is Functor.
    In programming language it can be expressed as inheritance: Functor is a base interface, Applicative Functor extends Functor and Monad extends Applicative (one of the problems in Haskell is absence of this inheritance and they are going to solve it in future versions).
    I don't tell that realisation of this inheritance is essential, but there is a problem:
    Defining realisations of Functor, Applicative and Monad protocols for a list you are defining Applicative Functor structure on lists three times, however this structures differ. And this is unexpected behabiour for me (it has nothing to do with Haskell, it just breakes my expectations carried from cathegory theory)

from fluokitten.

blueberry avatar blueberry commented on September 17, 2024

If you'd provide an implementation that is better than existing, I'll be glad to consider including it in fluokitten.

from fluokitten.

adavydow avatar adavydow commented on September 17, 2024

Great! I was going to provide such a realisation anyway, but I'll always
prefer collaboration to competing realisations.

On Tue, Dec 16, 2014 at 8:34 PM, Dragan Djuric [email protected]
wrote:

If you'd provide an implementation that is better than existing, I'll be
glad to consider including it in fluokitten.


Reply to this email directly or view it on GitHub
#17 (comment)
.

from fluokitten.

adavydow avatar adavydow commented on September 17, 2024

I made changes we discussed in a fork. Here is a changelog: https://github.com/adavydow/fluokitten/blob/master/CHANGELOG.md. What do you think about changes like this?
(Currently performance is a bit slower, because for test purposes I removed specialized functor and variadic implementations, but I'm going to return them)

from fluokitten.

blueberry avatar blueberry commented on September 17, 2024

I discussed variadic fmap in the first response and do not agree with your argumentation. Not only the changes are breaking, but the three conditions you mention in the changelog are pulled from thin air - all existing fluokitten implementations satisfy all functor, applicative and monadic laws already. Also, you just removed many tests that started failing once you introduced the changes.

Having said that, nothing should stop you from releasing the library that is suited to your liking, but please do not call it Fluokitten, and do not use Fluokitten's versioning since that will cause confusion with users when I release version 0.4.0.

from fluokitten.

adavydow avatar adavydow commented on September 17, 2024

ok

On Sat, Dec 20, 2014 at 12:31 PM, Dragan Djuric [email protected]
wrote:

I discussed variadic fmap in the first response and do not agree with your
argumentation. Not only the changes are breaking, but the three conditions
you mention in the changelog are pulled from thin air - all existing
fluokitten implementations satisfy all functor, applicative and monadic
laws already. Also, you just removed many tests that started failing once
you introduced the changes.

Having said that, nothing should stop you from releasing the library that
is suited to your liking, but please do not call it Fluokitten, and do not
use Fluokitten's versioning since that will cause confusion with users when
I release version 0.4.0.


Reply to this email directly or view it on GitHub
#17 (comment)
.

from fluokitten.

Related Issues (16)

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.