
2 Nov
2004
2 Nov
'04
5:32 a.m.
Put the data declaration in a module, export the type, but not the constructor you want to hide:
module Shape (Shape(Square), circle) where
Since we were talking about 'what can one do with a constructor as compared with a function', it should be mentioned that this also has a disadvantage: you loose pattern matching outside the module. I.e. no longer can say [..] BTW, would it be possible (in principle) to allow constructor export 'read-only', so matching against a constructor is allowed but not constructing a value?
OCaml has this:
http://caml.inria.fr/ocaml/htmlman/manual021.html#htoc99
--KW 8-)
--
Keith Wansbrough