3 ms·
> Yes there is, the functor. What we have is a functor F, which would be defined as in: module F = functor (X: S) -> .... If you have two modules A and
by more_original 10y ago
> Yes there is, the functor.
What we have is a functor F, which would be defined as in:
module F =
functor (X: S) -> ....
If you have two modules A and B of signature S, then you can form F(A) and F(B) and these are both modules. Now where are the maps from F(A) to F(B)? Just saying "the functor" does not explain this.
> Just repeating a false statement won't make it come true.
Exactly!
- MustardTiger 10y agoI can't teach you ocaml on hn. If you want to learn, try this: https://realworldocaml.org/ https://realworldocaml.org/
- more_original 10y agoOk, so you can't (or don't want to) actually back up your claim that OCaml functors have the same meaning as functors in Haskell. Which is to be expected, because it's bogus. I know OCaml fairly well. The reason you can't show me the map from F(A) to F(B) is that it's not there. If you want to claim a relation between OCaml functors and category-theoretic functors, then you must be able to justify your claims. Saying "functors represent functions from a module to a module. Oh hey, that sounds just like the standard definition of a functor." is just not a convincing argument.
- MustardTiger 10y ago>The reason you can't show me the map from F(A) to F(B) is that it's not there. That is literally the functor. Seriously, read the chapter on modules.
- more_original 10y ago> 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.
- tome 10y ago> 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.
- more_original 10y agoYes, 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.
- tome 10y agoI know you know :) I'm just reinforcing your point.
- MustardTiger 10y agoSeriously, read the book instead of repeating nonsense: https://realworldocaml.org/v1/en/html/functors.html https://realworldocaml.org/v1/en/html/functors.html
- deleted 10y ago[deleted]