[Haskell-beginners] Defining of subset of constructors as valid values

Lev Broido lev.broido at gmail.com
Mon Jan 18 04:32:21 EST 2010

Hi all
I have the following code :

data CmdTiming  = RAS Time | CAS Time | PCH Time | ACT Time deriving

data Command  =
  RD_CMD {bank :: Int, col :: Int }  |
  WR_CMD {bank :: Int, col :: Int}  |
  ACT_CMD {bank :: Int, row :: Int} |
  PCH_CMD {bank :: Int} deriving Show

I'd like to have something like :
RD_CMD {bank :: Int, col :: Int,timing :: RAS Time }
to limit possible values to RAS Time .

The reason I use constructors is differentiate whether current value is
applicable to some function , getting CmdTiming as parameter or not .

I am not sure this is valid definition since RAS Time is not type .

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100118/a47441b8/attachment.html

More information about the Beginners mailing list