ยค Transl, idT

Types

data Transl l g = Transl (l -> g) (g -> Maybe l)

idT :: Transl b b

Description

Constructors in Haskell are not first class values, that is, they can not be passed as argument to a function and then used in a pattern to match agains a value.

To be able to pass constructors as arguments to functions and use them both to construct and destruct values, we use the type Transl. With a a little help from cpp, we can easily construct Transl values from constructors:

#define CON(c) (Transl (c) (\x->case x of c y->Just y;_->Nothing))

See Also

The menu bar fudget: menuBarF.