Hacker News new | ask | show | jobs
by danharaj 2987 days ago
I grepped a typical project and saw these. I think they can be divided into a few different kinds of extensions.

This extension fixes a defect in the spec as far as I'm concerned:

* ScopedTypeVariables

Syntactic extensions that make certain code forms lighter:

* LambdaCase * MultiWayIf

* OverloadedStrings * RecursiveDo

* TypeApplications * PatternGuards

* KindSignatures

Code Generation:

* DeriveFunctor * DeriveTraversable

* DeriveFoldable * DeriveGeneric

* StandaloneDeriving * GeneralizedNewtypeDeriving

Extensions to the type system. These can be misused so they should be respected.

* MultiParamTypeClasses (Can weaken type inference)

* FunctionalDependencies (Helps type inference with MultiParamTypeClasses, these two together compete with TypeFamilies for functionality)

* FlexibleInstances (Can be a bit sketch, actually) * FlexibleContexts

* UndecidableInstances (Surprisingly mostly benign)

* TypeFamilies (Type level programming should be kept to a minimum. Can kill type inference)

* GADTs (Very powerful, sparingly appropriate)

* RankNTypes (Higher rank types are very expressive but have much worse type inference)

Unpleasant extensions that cope with the realities of serious engineering:

* TemplateHaskell

* CPP

Very Spicy extensions that I avoid unless they're really really appropriate:

* PolyKinds * TypeInType

I am mostly neutral or unfamiliar with the others. The only extension I vehemently oppose is RecordWildCards because it is a binding form that doesn't mention the names it binds. It can get really confusing!

2 comments

So I've developed a medium-large Haskell project that used nearly - but not quite all - of those same extensions. I would never think to describe this as "a few lightweight GHC extensions". To me - and I think most others - it's just normal Haskell, but why even bring up "standardish" if this is what you do?
I got this list from a project involving a lot of people. If I'm in charge of the project the list gets much thinner :-)

Most of these extensions have been around for like 10 years now and are well understood. They integrate well with the language without impacting Haskell2010 code. For example, RankNTypes or any of the code gen ones.

I shouldn't have said "a few" though! There's lots of light extensions. The only ones I consider heavy are some of the type system ones, CPP and TemplateHaskell. TypeInType is the heaviest by far.

Hey thank you!

I really appreciate it that you took the time to write that out.

I want to see this programmer who doesn't jump at the opportunity to give their opinion on programming :p you're welcome