Suppose there is a library module Foothat is not under my control:
module Foo (Foo, thing) where
data Foo = Foo Int
thing :: Foo
thing = Foo 3
Now suppose I have my own library module that re-exports thingfrom the module Foo.
module Bar (Foo.thing, getBar) where
import qualified Foo
type Bar = Foo.Foo
getBar :: Bar -> Int
getBar (Foo i) = i
For compatibility reasons, I do not want to export another thing. I want me to export Foo.thing, so if the user imports the modules Fooand Barthey will get the same thingand there will be no name clash.
Now suppose we have a third module that uses Bar.
module Main where
import Bar
Download the third one in ghci.
[1 of 3] Compiling Foo ( Foo.hs, interpreted )
[2 of 3] Compiling Bar ( Bar.hs, interpreted )
[3 of 3] Compiling Main ( test.hs, interpreted )
Ok, modules loaded: Main, Bar, Foo.
ghci> :t thing
thing :: Foo.Foo
ghci> :t getBar
getBar :: Bar -> Int
ghci> getBar thing
3
ghci> :info Bar
type Bar = Foo.Foo -- Defined at Bar.hs:3:6-8
ghci , , thing Bar Foo.Foo, , thing Bar. thing?