Allow import declarations anywhere in the module

Tickets: #82

There is no problem in theory with allowing import declarations to be placed anywhere at the top level of a module, instead of requiring them to be before all the value declarations as in Haskell 98.


  • simplifies the syntax, more consistent
  • makes it easier to add a temporary import (eg. imagine using 'trace' for debugging, you can put 'import Debug.Trace' right next to the use, rather than at the top of the module where you'll probably forget about it)
  • simpler for tools that auto-generate code, or annotate existing code (eg. Happy wants to add imports sometimes)
  • Java has been criticised for having a similar restriction: "Importing packages: A brief example of design issues"


  • tools that collect imports have to parse the whole file (eg. GHC's dependency analyser)
  • can't easily see what is imported
Last modified 13 years ago Last modified on Jan 31, 2006 11:32:59 AM