Abstract data types
Tue, 31 Oct 2000 12:27:14 +0000
> I have attached our module for the abstract data type Stack
> (we follow the Haskell 98 report and don't want to go into
> 1.4 compatibility). We expected the representation of stacks
> were hidden but Hugs let us write an expression with the
> "hidden" constructor StackC:
> Stack> :l Stacks
> Reading file "Stacks.hs":
> Dependency analysis........
> Type checking..............
> Hugs session for:
> Stacks> StackC 
> StackC 
> This problem occurs only in the top level, if we program a
> client module importing the module Stacks and we try to
> write a expression using directly StackC then Hughs gives an
> error message (great!).
> This is a bug in the top level, isn't it?
This is not a bug, it's a Feature[TM]! Notice the prompt says "Stacks>". This means that you are "in" the module Stacks, and so can see everything visible to a top-level function in the module Stacks.
If you write another file, say Main.hs, containing just the single line "import Stacks", then do ":l Main", you will find
Hugs session for:
Type :? for help
Main> StackC 
ERROR: Undefined constructor function "StackC"
which I think is what you wanted.
Keith Wansbrough <firstname.lastname@example.org>
Cambridge University Computer Laboratory.