Regular expressions as Haskell Type Generators?

Ketil Z. Malde ketil@ii.uib.no
26 Feb 2003 08:12:06 +0100


Steffen Mazanek <Steffen.Mazanek@UniBw-Muenchen.de> writes:

> I am wondering if it would be worth while (and possible) to allow the
> definition of types by regular expressions, e.g.

> data Date = Date #RegExp([0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9])

> or easier with some auxiliary constructs.

Not sure I follow this.  Why not declare Date = Date String (or
whatever format), making the constructor private?  Then you could
of course export date-constructing functions that maintain any
invariants you like. 

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants