7.2. Restricted type synonyms

Restricted type synonyms are a mechanism for defining abstract datatypes. You can achieve similar effects, and more portably, using the Haskell 98 module system.

The idea is that you can say that a type synonym is transparent in the definitions of certain functions (the operations on the type), but opaque elsewhere, by writing

type Table a b = [(a,b)] in
    empty :: Table a b,
    isEmpty :: Table a b -> Bool,
    add :: a -> b -> Table a b -> Table a b,
    search :: a -> Table a b -> Maybe b

empty = []
isEmpty = null
add a b t = (a,b):t
search = lookup
or equivalently
type Table a b = [(a,b)] in empty, isEmpty, add, search

empty :: Table a b
empty = []

See Section 7.3.5 of the Hugs 98 User Manual for details.