Hello Joost,

Sunday, December 30, 2007, 5:24:59 PM, you wrote:

> data ClockTime = TOD Integer Integer

it declares type with name ClockTime (which you may use on type
signatures, other type declarations and so on) with one constructor
TOD accepting two Integer values. the only way to construct value of
this type is to apply TOD to two Integer expressions (believe it or
not but this declaration automatically defines TOD as function with
the following signature:

TOD :: Integer -> Integer -> ClockTime

f.e.:

seconds2clockTime :: Double -> ClockTime
seconds2clockTime s = TOD (floor(s)) (round(s*1e12)

the only way to deconstruct values of this type is to use TOD
constructor in parser matching, f.e.:

clockTime2seconds :: ClockTime -> Double
clockTime2seconds (TOD s p)  =  fromInteger(s) + fromInteger(p)/1e12




-- 
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to