Re: Overloading and Literal Numerics

2002-06-27 Thread Jon Fairbairn
> Alain Cremieux wrote: > I am trying to build a functional firewall generator. The first part > describes the available protections (kernel, anti-address spoofing, etc.). > The second desribes every protocol, and the necessary rules if the > corresponding service is enabled (e.g. open the http po

Re: Overloading and Literal Numerics

2002-06-27 Thread CREMIEUX Alain
Jon Fairbairn wrote : > Hi, > I am trying to create an overloaded function "à la Java" to be able to > call it either with a string or a number. > Ex : > definePort "http" > definePort 80 > but I have problem with restrictions in Haskell's type system > Is there a better solution ? If we knew /w

Re: Overloading and Literal Numerics

2002-06-27 Thread Jon Fairbairn
> Jon Fairbairn <[EMAIL PROTECTED]> writes: > > > data Port = 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

Re: Overloading and Literal Numerics

2002-06-27 Thread Ketil Z. Malde
Jon Fairbairn <[EMAIL PROTECTED]> writes: > data Port = 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

Re: Overloading and Literal Numerics

2002-06-27 Thread Jon Fairbairn
> Hi, > I am trying to create an overloaded function "à la Java" to be able to > call it either with a string or a number. > Ex : > definePort "http" > definePort 80 > but I have problem with restrictions in Haskell's type system > Is there a better solution ? If we knew /why/ you wanted to do t

Re: Overloading and Literal Numerics

2002-06-26 Thread Hal Daume III
The problem is that you might have: instance Poly Double where ... and then when you say: po 5 it doesn't know whether this is an Int or a Double. writing po (5::Int) should be sufficient. -- Hal Daume III "Computer science is no more about computers| [EMAIL PROTECTED] than astrono

Overloading and Literal Numerics

2002-06-26 Thread Alain Cremieux
Hi, I am trying to create an overloaded function "à la Java" to be able to call it either with a string or a number. Ex : definePort "http" definePort 80 but I have problem with restrictions in Haskell's type system (or with my lack of experience with it). The program : data PolyType = MkPolyLef