[Haskell-beginners] Check constructor's field numeric value at compile time

Dmitriy Matrosov sgf.dma at gmail.com
Tue Sep 2 19:32:35 UTC 2014


Hi.

I have a type

data Interval	= Seconds Float
		| MicroSeconds Int

The Float field of data constructor Seconds should be >= 1, and Int 
field of constructor MicroSeconds should be in the range from 0 to 1000000.

How can i write this constraints so they're checked at compile time, not 
at runtime?

--
     Dmitriy Matrosov


More information about the Beginners mailing list