5 | record Quantity where
12 | show (Qty Z Nothing) = "*"
13 | show (Qty Z (Just (S Z))) = "?"
14 | show (Qty (S Z) Nothing) = "+"
15 | show (Qty min max) = "{" ++ show min ++ showMax ++ "}"
18 | showMax = case max of
20 | Just max' => if min == max'
22 | else "," ++ show max'
25 | between : Nat -> Nat -> Quantity
26 | between min max = Qty min (Just max)
29 | atLeast : Nat -> Quantity
30 | atLeast min = Qty min Nothing
33 | atMost : Nat -> Quantity
34 | atMost max = Qty 0 (Just max)
37 | exactly : Nat -> Quantity
38 | exactly n = Qty n (Just n)
41 | inOrder : Quantity -> Bool
42 | inOrder (Qty min Nothing) = True
43 | inOrder (Qty min (Just max)) = min <= max