Mark T.B. Carroll wrote:
I have a program that basically has,
data Expression =
Value Value
| EVariable Variable | other stuff ...
data Value = VNumber Number | other stuff ...
data Variable = Variable { variable_name :: String, variable_time ::
Expression }
Johan Nordlander wrote:
For comparison, the example could be formulated in O'Haskell as
follows:
data Variable = Variable { variable_name :: String, variable_time ::
Expression }
data Number = Number { value :: Double, dimension :: Dimension }
data Value Number = other stuff
I have a program that basically has,
data Expression =
Value Value
| EVariable Variable | other stuff ...
data Value = VNumber Number | other stuff ...
data Variable = Variable { variable_name :: String, variable_time :: Expression }
data Number = Number { value ::
I think this is more or less the standard way of doing it. I don't think
type classes are the right thing to do. Usually constructors are prefixed
with the first character of their type in situations like this (or so I've
seen), so you get:
data Expression = EValue Value | EVariable Variable |