2

Refer to https://wiki.haskell.org/Smart_constructors and module code:

module Resistor (
         Resistor,       -- abstract, hiding constructors
         metalResistor,  -- only way to build a metal resistor
       ) where

 ...

When I try this in ghci, I am able to call both metalResistor and Metal. Metal was supposed to be hidden. What should I do to properly hide the Resistor value constructor?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
jpmathew
  • 21
  • 1
  • 3
    That's because GHCi ignores the list of exports and exports everything from the module. – jub0bs Jun 25 '15 at 08:30
  • 1
    **Do not trust GHCi**. It behaves differently from GHC. If you find something odd when using GHCi try to past the code into a file and compile it. – Bakuriu Jun 25 '15 at 08:32

0 Answers0