# Durations and Intervals operations

## Converting Durations

Since all the module types implement the Duration type class, we can use convertDuration to convert from a duration type to another.

convertDuration :: forall a b. Duration a => Duration b => a -> b


The only thing we need to do is pass it one of the duration types (Days, Hours, Minutes, Seconds, Milliseconds ), and then specify an output duration type (or use the result in a context where the compiler can infer the type).

myMinutesDuration :: Minutes
myMinutesDuration = Minutes 60.0

myHoursDuration :: Hours
myHoursDuration = convertDuration myMinutesDuration -- Hours 1.0

-- And so on for the rest...


## Negating Durations

It’s possible to negate a duration by using negateDuration:

negateDuration :: forall a. Duration a => a -> a


For example:

myDuration :: Days
myDuration = Days 10.0

myDurationNeg :: Days
myDurationNeg = negateDuration myDuration -- ^ -10 days