Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use new Haskell language extensions in favour of the old ones?

When starting a new Haskell project which needs language features that are offered by both new and older extensions, which should I use? The new one or the old one? For example:

  • GADTs supersede ExistentialQuantification.
  • TypeFamilies in many cases supersede FunctionalDependencies.
  • etc. (if you have more examples feel free to add here)

I incline towards the newer ones as they feel cleaner and they add more features to the language in a unified manner. However, the older ones are supported by more compilers, they're used in existing libraries and perhaps also better known among programmers.

Update: As mentioned in answers/comments, the "supersede" relationships above are not completely precise. However, I'm interested in (often occurring) cases when a task can be accomplished equally well by several extensions.

like image 239
Petr Avatar asked Nov 16 '12 18:11

Petr


1 Answers

"supersede" is very ambiguous here.

For language features that have semantics that overlap with other features, we can recognize a few cases:

  • some features generalize existing ones
  • some offer alternative approaches

In the case of more general features, there are risks and benefits. The generality can impact many other parts of the language, or be restricted. In the latter, choose the general case.

If it is a choice between alternative approaches, with no strict ordering, such as FDs or ATs, then it is harder to give general advice.

So, in summary, "no" , there's no obvious reason to use "new" things over "old" things, when it comes to language features. They don't sort that way.

like image 196
Don Stewart Avatar answered Sep 23 '22 20:09

Don Stewart