1 | module TyRE.Text.Quantity
4 | record Quantity where
11 | show (Qty Z Nothing) = "*"
12 | show (Qty Z (Just (S Z))) = "?"
13 | show (Qty (S Z) Nothing) = "+"
14 | show (Qty min max) = "{" ++ show min ++ showMax ++ "}"
17 | showMax = case max of
19 | Just max' => if min == max'
21 | else "," ++ show max'
24 | between : Nat -> Nat -> Quantity
25 | between min max = Qty min (Just max)
28 | atLeast : Nat -> Quantity
29 | atLeast min = Qty min Nothing
32 | atMost : Nat -> Quantity
33 | atMost max = Qty 0 (Just max)
36 | exactly : Nat -> Quantity
37 | exactly n = Qty n (Just n)
40 | inOrder : Quantity -> Bool
41 | inOrder (Qty min Nothing) = True
42 | inOrder (Qty min (Just max)) = min <= max