Deriving instance for Foreign.C.Error.Errno (trac 2261)

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Mon May 5 18:31:03 EDT 2008


On Mon, 2008-05-05 at 08:16 -0400, Thomas M. DuBuisson wrote:
> Errno, the Haskell encapsulation of the CInt 'errno' value, should be an
> instance of the commonly used type classes so higher level data
> structures that include it aren't bothered.
> 
> This change will break code that has custom instances for Errno, but
> this should be little (if any) code.
> 
> A patch is attached to the trac ticket to derive Show and Ord while Eq
> remains a custom instance.  One could argue that, like Eq, Show and Ord
> should be customized to provide a identical result for all 'invalid'
> errno's - any thoughts on if this is necessary and what the corner case
> result would be?
> 
> http://hackage.haskell.org/trac/ghc/ticket/2261

Having it an instance of Ord and Show seems fine.

If the Eq instance equates all the invalid errnos then the Ord instance
should do so too because it is important that:
compare a b == Eq  <=>  a == b

Duncan





More information about the Libraries mailing list