Module Import
import syntax
Take an Example:
module Shapes
where
import Data.Number (pi)
import Data.Ord (abs)
data Shape = Circle Number Number Number
| Rectangle Number Number Number Number
surface :: Shape -> Number
surface (Circle _ _ r) = pi * r * r
surface (Rectangle x1 y1 x2 y2) = (abs $ x2 - x1) * (abs $ y2 - y1)
import all (implicitly)
The following will import all of the values and types in module A:
module App where
import Shapes
import explicitly
Values, operators (wrapped in parentheses), type constructors, data constructors, and type classes can all be explicitly imported.
A type constructor can be followed by a list of associated data constructors to import in parentheses.
import Shapes (Shape(Circle))
note
For 'import', we can partially import value constructors; but this does not work for export!
A double dot (..) can be used to import all data constructors for a given type constructor:
import Shapes (Shape(..))