
In my older (1992) intro programming book, the author uses the keyword "abstype" instead of "data" inside of module code. From what I can gather, abstype is supposed to hide constructors. But I've never seen this keyword used in any modern tutorials I've gone through. Is "abstype" still a valid keyword? Is is still relevant? -- frigidcode.com theologia.indicium.us

abstype is not currently a keyword in Haskell. To hide constructors
from client modules, use an explicit module export list, and don't
include the constructors in the list.
For example,
module MyModule ( Foo ) where
data Foo = Bar Int | Baz Float | Bat Double
will make Foo an abstract type, since Bar, Baz, and Bat are not exported.
Similarly,
module MyModule ( Foo ) where
data Foo = Foo Int
will also make Foo an abstract type, since Foo in the export list
refers to the type Foo, not the constructor Foo (which happens to have
the same name). To export Foo and its constructors, use Foo (..) in
the export list, or list the constructors explicitly: Foo ( Bar, Baz,
Bat ) for the first example, or Foo ( Foo ) for the second example.
Hope that helps.
Alexander
On 14 August 2011 22:06, Christopher Howard
In my older (1992) intro programming book, the author uses the keyword "abstype" instead of "data" inside of module code. From what I can gather, abstype is supposed to hide constructors. But I've never seen this keyword used in any modern tutorials I've gone through. Is "abstype" still a valid keyword? Is is still relevant?
-- frigidcode.com theologia.indicium.us
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (2)
-
Alexander Dunlap
-
Christopher Howard