News for hackers. Stuff that matters.
Re:Pitfalls in Haskell by more_original on Wednesday August 24, 2016 @05:35PM (#12355425)
> That is literally the functor.

That would be an answer for Haskell (though a proper one would refer to fmap), but it does not work like that in OCaml. You do know some OCaml, right?

But if it's so obvious, then you can say how it works for the following concrete example:

  module type S = sig
    type t
    val f: t -> int
  end
  
  module F = functor (X: S) -> struct
    type s = X.t * X.t
    let g x = X.f x + X.f x
  end
  
  module A : S = struct
    type t = float
    let f x = int_of_float x
  end
  
  module B : S = struct
    type t = int
    let f x = 2*x
  end
  
  module X = F(A)
  module Y = F(B)
How do I get from X to Y by "literally the functor"?

The point is: In the ML module system there is no equivalent to fmap: (A -> B) -> (F A -> F B), i.e. the functor action on morphisms. So, functors in Haskell and OCaml are different things. If you want to claim otherwise, you'll have to make an actual argument for it.

Re:Pitfalls in Haskell by tome on Wednesday August 24, 2016 @06:30PM (#12355751)
> How do I get from X to Y by "literally the functor"?

NB You only need to get from X to Y in ways that arise from getting from A to B. Since there doesn't seem to be any relevant concept of morphism it's hard to see how ML functors are anything other than trivially category theoretical.

Re:Pitfalls in Haskell by more_original on Wednesday August 24, 2016 @06:35PM (#12355778)
Yes, I know! That's the point I'm trying to make. This whole discussion is about MustardTiger's claim that functors in OCaml have the same meaning as Functor in Haskell. While the latter model functors in the category-theoretic sense, the same cannot be said for the former.
Re:Pitfalls in Haskell by tome on Thursday August 25, 2016 @03:25AM (#12357390)
I know you know :) I'm just reinforcing your point.
Re:Pitfalls in Haskell by MustardTiger on Thursday August 25, 2016 @10:08AM (#12359092)
Seriously, read the book instead of repeating nonsense: https://realworldocaml.org/v1/en/html/functors.html