Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom Prelude module -- bad idea?

Tags:

haskell

I just realized that I can define my own Prelude module and carefully control its exports. Is this considered bad practice?

Advantages:

  • No need to repeatedly import a "Common" module in large projects.

  • No need to write "import Prelude hiding (catch)".

like image 831
Arjun Guha Avatar asked Nov 30 '12 16:11

Arjun Guha


1 Answers

In general its a bad idea, as you end up with code written in your own idioms that isn't going to be easy to maintain by others.

To communicate with others you need a shared language of symbols. The Prelude is our core language, so if you redefine it, expect confusion.

The exception to this rule would be when developing an embedded domain-specific language. There, making a custom Prelude is entirely a good idea, and is indeed why it is possible to redefine the Prelude (and inbuilt syntax) in the first place.

By all means have your own additional modules, but don't override the Prelude.

like image 117
Don Stewart Avatar answered Oct 12 '22 04:10

Don Stewart