3 ms·
What do you mean by "without functors?" F# doesn't have a way to define a `map` function that is generalizable to arbitrary data types?
by kyllo 11y ago
What do you mean by "without functors?" F# doesn't have a way to define a `map` function that is generalizable to arbitrary data types?
- pdpi 11y agoOCaml functors are not the same thing as Haskell functors — in OCaml they refer to mappings from modules to modules. https://realworldocaml.org/v1/en/html/functors.html https://realworldocaml.org/v1/en/html/functors.html
- ufo 11y ago"Functor" might just be the most overloaded term in computer programming... Just of the top of my head it has totally different meanings in Ocaml, Haskell and C++.
- kyllo 11y agoThey're not totally different between OCaml and Haskell. They're based on the same concept from Category Theory: a mapping of objects and morphisms from one category to another. It's just that Haskell functors are at the type level and OCaml's functors are at the module level. Apparently F# has support for neither style of functor--it doesn't have parametric modules and it also doesn't have typeclasses. So in F# `map` is defined independently for each type: Set.map : ('a -> 'b) -> 'a Set -> 'b Set Seq.map : ('a -> 'b) -> 'a seq -> 'b seq List.map : ('a -> 'b) -> 'a list -> 'b list Array.map : ('a -> 'b) -> 'a [] -> 'b []