Mapa mental
Haskell Modules
Contenido del mapa
Haskell Modules
We need to import the modules before we can use it.
- How?
- Using the keyword: import MyModule
- import Data.List
- After import the module Data.List all the functions in that package will be available to us.
- import Data.List
- Using the keyword: import MyModule
- How?
Also we can import the functions needed in a module.
- import Data.List(nub)
- On the other way around we can hide some function from the namespace
- import Data.List hiding nub
- On the other way around we can hide some function from the namespace
- import Data.List(nub)
Sometimes we can have conflicts with function form diferents modules with the same same so in tha case we need to reference it with a qualified indentifier
- import qualified Data.Map
- Other way to do an import is
- import qualified Data.Map as M
- We are using M as alias to call the function in the module Data.Map
- import qualified Data.Map as M
- Other way to do an import is
- import qualified Data.Map
Build in Modules
- Data.List
- Functions related with lists.
- Data.Char
- Functions to deal with chars
- Data.Map
- Function to deal with key value pair where the order doesn't matter
- Data.Set
- Functions to deal with Sets, contains unique elements and they are ordered.
- Data.List
How to define our own Modules
- As a good practice is better to group functions related to put it in the same module.
- module Geometry ( sphereVolume ) where
- module Geometry ( sphereVolume ) where sphereVolume :: Float -> Float sphereVolume radius = (4.0 / 3.0) * pi * (radius ^ 3)
- We must put the Geometry.hs in the same path of the main module in order to import it in the running module.
- module Geometry ( sphereVolume ) where sphereVolume :: Float -> Float sphereVolume radius = (4.0 / 3.0) * pi * (radius ^ 3)
- module Geometry ( sphereVolume ) where
- As a good practice is better to group functions related to put it in the same module.
Información
- Descripción
- Mapa Mental sobre Haskell Modules, creado por Nicolas Rubiano el 22/09/2018.
- Creado por
- Nicolas Rubiano
- Visitas
- 0
- Valoración
Más sobre Haskell Modules and Libraries