8 | record Quantity where
17 | show (Qty Z Nothing) = "*"
18 | show (Qty Z (Just (S Z))) = "?"
19 | show (Qty (S Z) Nothing) = "+"
20 | show (Qty min max) = "{" ++ show min ++ showMax ++ "}"
23 | showMax = case max of
25 | Just max' => if min == max'
27 | else "," ++ show max'
31 | between : Nat -> Nat -> Quantity
32 | between min max = Qty min (Just max)
36 | atLeast : Nat -> Quantity
37 | atLeast min = Qty min Nothing
41 | atMost : Nat -> Quantity
42 | atMost max = Qty 0 (Just max)
46 | exactly : Nat -> Quantity
47 | exactly n = Qty n (Just n)
51 | inOrder : Quantity -> Bool
52 | inOrder (Qty min Nothing) = True
53 | inOrder (Qty min (Just max)) = min <= max