two easy questions

Mike T. Machenry dskippy@ccs.neu.edu
Thu, 20 Feb 2003 12:12:47 -0500


I tried this. It doesn't work. succ Blue is an exception. Anybody else know
how this should be done?

Thanks,
-mike

On Thu, Feb 20, 2003 at 08:00:04AM -0800, Hal Daume III wrote:
> > Question 1: Is there an easier, more elegant way to write this code?
> 
> For the most part, no.
> 
> > Question 2: Is there a way to express the following relationship?
> >  I want to have a set of symbols with ordering and another set that is
> > part of that ordering but with a different parent. For exammple,
> > 
> > data Player = Detective | Fugitive deriving (Enum)
> > data Detective = Red | Green | Blue deriving (Enum)
> > data Fugitive = MrX deriving (Enum)
> 
> How about something like:
> 
> > data Player = Detective Detective | Fugitive Fugitive deriving (Enum)
> > data Detective = Red | Green | Blue deriving (Enum)
> > data Fugitive  = MrX deriving (Enum)
> 
> (I'm not sure if the deriving Enum on Player will be exactly what you want
> -- I think so though.  I don't derive this class very often.)
> 
> Then you can test detectiveness by:
> 
> > isDetective (Detective _) = True
> > isDetective _             = False
> 
> HTH
> 
>  - Hal
> 
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell