Data structure definitions

Johan Nordlander nordland@cs.chalmers.se
Wed, 9 Oct 2002 08:57:07 +0200


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 }
>   data Number = Number { value :: Double, dimension :: Dimension }
>
>   newtype VariableCount = VariableCount (Variable, Number)
>
> The VNumber and EVariable constructors are ugly, though, [...]
>

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

   data Expression > Value, Number = other stuff

   newtype VariableCount = VariableCount (Variable, Number)

-- Johan