Haskell/Libraries

Haskell has a rich and growing set of libraries. They fall into several groups:


 * The Standard Prelude (often referred to as just "the Prelude") is defined in the Haskell 2010 standard and imported automatically to every module you write. It defines standard types such as strings, lists, numbers, and the basic functions on those, such as arithmetic,, and.


 * The Standard Libraries are also defined in the language standard, but you have to import them when you need them. The specification of these libraries can also be found in the Haskell 2010 standard.


 * Since 1998, the Standard Libraries have been gradually extended, and the resulting de facto standard is known as the Base Libraries. The same set is available for both Hugs and GHC.


 * Other libraries may be bundled with the various compilers. In particular, GHC includes a handful of commonly used libraries, including important packages such as,  , and.


 * Many other libraries are available from Hackage, and can be installed using the  utility.

When Haskell 98 was standardized, modules were given a flat namespace. That turned out to be inadequate, and a hierarchical namespace has been added by allowing dots in module names. For backward compatibility the standard libraries can still be accessed by their non-hierarchical names, so the modules  and   both refer to the standard list library.

For details of how to import libraries into your program, see the Modules chapter. For an explanation of the Cabal system for packaging Haskell software see Haskell/Packaging.

Haddock Documentation
Library reference documentation is generally produced using the Haddock tool. The libraries shipped with GHC are documented in this way. You can view the documentation online, and if you have installed GHC then there should also be a local copy.

Haddock produces hyperlinked documentation, so every time you see a function, type, or class name you can click on it to get to the definition. The sheer wealth of libraries available can be intimidating, so this tutorial will point out the highlights.

Note that Haddock cross-references types and classes by instance. For example, in the  library the   data type is listed as an instance of  :

If you declare a type  is an instance of   then the type   will automatically be an instance of   as well. If you click on the word  in the document then you will be taken to the definition of the   class and its (very long) list of instances. The instance for  will be down there as well.