A module is the unit of organization that the Haskell programming language uses to collect together declarations of values, functions, datatypes, type classes, and type class instances. Any time you use import in Haskell, you are importing declarations from a module. Let us look at an example from the chapter exercises:
{-# LANGUAGE NoMonomorphismRestriction #-}
module DetermineTheType where
-- ^ name of our module
Here, we turn our Haskell source file into a module, and we name it DetermineTheType. We include a directive to the compiler to disable the monomorphism restriction before we declare the module. Also, consider the following example using import:
import Data.Aeson (encode)
-- ^ the module Data.Aeson
import Database.Persist
-- ^ the module Database.Persist
In the above example, we are importing the function encode declared in the module Data.Aeson along with any type class instances. With the module Database.Persist, we are importing everything it makes available.
A module is the unit of organization that the Haskell programming language uses to collect together declarations of values, functions, datatypes, type classes, and type class instances. Any time you use
import
in Haskell, you are importing declarations from a module. Let us look at an example from the chapter exercises:Here, we turn our Haskell source file into a module, and we name it DetermineTheType. We include a directive to the compiler to disable the monomorphism restriction before we declare the module. Also, consider the following example using import:
In the above example, we are importing the function
encode
declared in the moduleData.Aeson
along with any type class instances. With the moduleDatabase.Persist
, we are importing everything it makes available.