How can I add constraints to a type in a data type in haskell?

Viewed 43

I have a data type called Time in Haskell that has hour, minute, and seconds.

data Time = Time
  { Hour :: Int,
    Minute :: Int,
    Second :: Int,
  }
  deriving (Show, Eq)

When defining a data type that holds an int value, how do you limit the int value between a range? I want to limit it to 0 to 24 for hour for example.

0 Answers
Related