Some times it is convenient to use both
limited import and renaming functionality of module together.
Arithmetic.hs
-- Arithmetic module implements simple Arithmetic functions module Arithmetic where addition :: Integer -> Integer -> Integer addition x y = (x+y) sub :: Integer -> Integer -> Integer sub x y = (x-y) mul :: Integer -> Integer -> Integer mul x y = (x*y) divide :: Integer -> Integer -> Double divide x y = (fromIntegral x / fromIntegral y)
test.hs
import Arithmetic as Arth import Arithmetic (divide, mul) processInfo :: Integer -> Integer -> Integer processInfo x y = Arth.addition x y + mul x y
*Main> :load test.hs [1 of 2] Compiling Arithmetic ( Arithmetic.hs, interpreted ) [2 of 2] Compiling Main ( test.hs, interpreted ) Ok, modules loaded: Arithmetic, Main. *Main> *Main> processInfo 10 20 230 *Main>
No comments:
Post a Comment