3 ms·
Not sure about the last two you listed, but those languages don't support parametric polymorphism which means that although you can write a `fmap` method for th
by smegma2 7y ago
Not sure about the last two you listed, but those languages don't support parametric polymorphism which means that although you can write a `fmap` method for things, the compiler can't check its type properly. At best you can write an interface, but that interface won't be able to guarantee that the functor returned by fmap is the same one you started with.
- hopia 7y agoJava and C# at least should support (parametric) polymorphism via Generics. In Haskell you don't need GHC Generics to achieve parametric polymorphism though, it's used for different things.
- rovolo 7y agoI think they mean type classes/constructors [1] since they're talking about fmap, though I'm not sure what the proper name is for that concept. What name would you use? They're trying to say that Java doesn't support writing a single function like so: <T<A> extends Iterable<A>, A, B> T<B> fmap(T<A> iterable, Function<A,B> mapper) I.e. you can't pass ArrayList<A> to a method which takes List<A> and maps to List<B> and know for certain that you get an ArrayList<B> out. [1] https://en.wikipedia.org/wiki/Type_class#Higher-kinded_polymorphism https://en.wikipedia.org/wiki/Type_class#Higher-kinded_polym...
- hopia 7y agoWell data constructors are a part of algebraic data types which don't really exist in OOP. Unless you consider the class itself (or an interface) or its constructor as the algebraic data type constructor, and its properties/parameters as the values. I'm not so sure fmap would make semantically as much sense in something like Java as it does in FP.