Skip to content

Haskell_conventions

Jutaro edited this page Oct 3, 2011 · 1 revision

Packages

  1. Organize all code as Cabal packages.

  2. Avoid circular module dependencies by introducing a module Types"packageName" for more complex packages (it is possibble to have a shortened PackageName here)

  3. For any bigger library package introduce a module with all exports called Export"packageName". This module reexports all the stuff.

  4. Use >>ghc-options: -Wall in the cabal file. (possibly with -fno-warn-name-shadowing -fno-warn-unused-do-bind) You may disable other warnings for a package (or for a module in a module header) Bring your code to zero warnings (this may be difficult when supporting different compiler and library versions with different imports)

  5. Use upper bounds in the cabal file for the build depends: e.g. containers >=0.2 && <0.5,

Modules

  1. Add a module header in the following form:
{- |
Module      :  <File name or $Header$ to be replaced automatically>
Description :  <optional short text displayed on contents page>
Copyright   :  (c) Authors ICS AG year
License     :  <license>

Maintainer  :  <email>
Stability   :  unstable | experimental | provisional | stable | frozen
Portability :  portable | non-portable (<reason>)

<module description starting at first column>
-}
  1. Add an export list to all modules (to make it easier to understand later, what is the interface)

  2. Add a Haddock Comment at least for every exported entity

  3. Use literal Haskell for writing papers, and not for production code

  4. Add a type declaration for every toplevel function

( Open: How to name modules? How to insert modules in hierarchy? Have a top category for project (Iron.) or not? Make an exception for general utilities like Text. or use Iron.Text.***?)

Clone this wiki locally