underlap,
@underlap@fosstodon.org avatar

New blog post: Understanding Haskell's type system

https://underlap.org/understanding-haskells-type-system

kosmikus,
@kosmikus@functional.cafe avatar

@underlap Nice blog post!

Some random comments: I think the section on "parametric polymorphism" comes a bit suddenly. I'm not quite sure about it's internal structure ("it usually applies to functions, but covers constants too" ? why is one the usual case, the other not?), but even more importantly, I'd have expected this part to somehow explain the relation between parametric polymorphism and overloaded types, yet it does not.

I'm not sure what part of the Wiki "infers concrete types" whenever possible refers to, but I think it's misleading here without further context?

Depending on how exhaustive you want to be, you might want to say that even Haskell 2010 does require type annotations in some cases (most notably for code with otherwise ambiguous types, and for code using polymorphic recursion).

underlap,
@underlap@fosstodon.org avatar

@kosmikus Thanks for the feedback!

  • I've repositioned the "parametric polymorphism" section

  • I'm not sure what the relation is between parametric polymorphism and overloaded types. Where do overloaded types come into the definition of head for example?

  • I've provided a link into the wiki

  • Your statement about Haskell 2010 seems to contradict my finding that Haskell 2010 has the principal type property. So was my finding wrong?

kosmikus,
@kosmikus@functional.cafe avatar

@underlap Regarding principal types: I think it's fair to say Haskell 2010 has principal types. Neither of the examples I gave contradicts this: in the case of ambiguous types there is a principal type, but that type is being rejected (without -XAllowAmbiguousTypes) because it does not allow calling a value of such a type without explicitly specifying which dictionary to pass (e.g. via explicit type applications). In the case of polymorphic recursion there also is a principal type, but type inference does not find it and rejects the program without an explicit type signature.

In contrast, with e.g. GADTs, you can really state programs which allow two or more incomparable Haskell types. Similarly, with rank-n types.

underlap,
@underlap@fosstodon.org avatar

@kosmikus FWIW https://wiki.haskell.org/Polymorphism distinguishes between parametric polymorphism (with no mention of overloading) and ad-hoc polymorphism which does mention overloading.

kosmikus,
@kosmikus@functional.cafe avatar

@underlap ah sorry, I did not follow the link, perhaps did not even notice that there was one...

  • All
  • Subscribed
  • Moderated
  • Favorites
  • haskell
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines