Search code examples
haskellmoduleghciname-hiding

Haskell modules: hidden names and ghci


I'm trying to export just a subset of names from a Haskell module, but ghci happily lets me access even the hidden names.

module Hiding (shown, calc) where

calc = shown * hidden

shown :: Int
shown = 3

hidden :: Int
hidden = 2

But when trying this in ghci I get:

Prelude> :l Hiding.hs 
[1 of 1] Compiling Hiding           ( Hiding.hs, interpreted )
Ok, modules loaded: Hiding.
*Hiding> hidden
2

What am I doing wrong?

(Edit: for what it's worth, I'm using ghci 6.12.3 on Arch Linux)


Solution

  • It looks like GHCi is loading your module for you to inspect it, i.e. putting you in the scope of the module. Two hints at that are the prompt *Hiding> and the fact that you accessed the hidden function.

    Edit:
    End there it is: http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluation.html#id3045728