Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Right. But OOP makes it central, and builds around it, while FP de-emphasizes it in preference to ADTs.

Strings are a good illustration. Instead of an abstract polymorphic String type, Haskell provided a concrete String type as an ADT. This proved too inflexible, which is why we have Text, lazy Text, ShortText, etc. Compare to NSString which also has multiple representations but hides them behind a single polymorphic interface.



"OOP makes it central, and builds around it, while FP de-emphasizes it in preference to ADTs."

ADTs are not an intrinsic part of FP, as not all FP languages even have them.

I'd also question whether ubiquitous polymorphism is overall a good thing in a language, or whether it's misguided complexity. In most OOP languages, any public method can be polymorphic, but a polymorphic function is inherently less predictable than one dispatches off a single type.


This sounds like haskell’s backpack, which lets you swap implementations of a model interface at will. But maybe I’m misunderstanding what you meant.

Polymorphism is front an central to everything in Haskell, which is why your comment sound off to me.


Or you use -XOverloadedStrings and then you also have in Haskell multiple representations that follow a single polymorphic interface.


It does not. -XOverloadedStrings unlocks `fromString :: String -> a.` That is not a polymorphic string interface; it's just syntax sugar for making something else from a string literal.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: