If I have a type

type WaterChem = CaHardness NaturalChem | Alkalinity NaturalChem

and I want to have the values of CaHardness and Alkalinity constrained to positive Int and between certain high and low values, I could do a newtype to creater a NaturalChem number, thus never less than 0, but what is the best practice to insure these values are between a certain range? Types in Haskell can't go that far, can they? Reading this tells me I can have some of what I want. How are type values that need to be constrained handled best practices? Again, the type world of Haskell seems to do some of the lifting, but I'd like some advice if I want to have both of my constraints.




--

Lawrence Bottorff
Grand Marais, MN, USA
borgauf@gmail.com