Overloading and Literal Numerics

Jon Fairbairn Jon.Fairbairn@cl.cam.ac.uk
Thu, 27 Jun 2002 11:09:07 +0100


> Jon Fairbairn <Jon.Fairbairn@cl.cam.ac.uk> writes:
> =

> > data Port =3D Tcpmux | Nbp | Echo_ddp | Rje | Zip | Echo_tcp | ...
> >              deriving Enum, ...
> > instance Num Port where ...
> =

> Or, alternatively, just use Strings, and have a portFromString first
> check /etc/services for a match, then try to parse the string as a
> positive integer, and finally generate an error if no valid port can
> be determined?

Possibly, if there's really no way of making sure the error
happens at compile time.

-- =

J=F3n Fairbairn                                 Jon.Fairbairn@cl.cam.ac.u=
k
31 Chalmers Road                                         jf@cl.cam.ac.uk
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)