Skip to main content

EXAMPLE_02_LIBRARY_FEES

Constant EXAMPLE_02_LIBRARY_FEES 

Source
pub const EXAMPLE_02_LIBRARY_FEES: &str = "spec library_fees\n\"\"\"\nLibrary Late Fees\n\nShows conditional logic with unless clauses.\nEasy to understand: books returned late incur fees.\n\"\"\"\n\nuses lemma units\n\ndata money: measure\n  -> decimals 2\n  -> unit eur: 1.00\n  -> minimum 0 eur\n\ndata book_kind: text\n  -> option \"regular\"\n  -> option \"reference\"\n  -> option \"new_release\"\n\ndata book_type:        book_kind\ndata is_first_offense: boolean\ndata due_date:         date\ndata return_date:      date\n\n\nrule days_overdue:\n  due_date...return_date as day as number\n\nrule daily_fee:\n  0 eur\n  unless book_type is \"regular\"     then 0.25 eur\n  unless book_type is \"reference\"   then 0.5 eur\n  unless book_type is \"new_release\" then 1 eur\n\nrule is_in_grace_period:\n  days_overdue <= 3\n  unless book_type is \"new_release\" then no\n\nrule total_fee:\n  days_overdue * daily_fee\n\nrule final_fee:\n  total_fee\n  unless is_first_offense   then total_fee * 50%\n  unless is_in_grace_period then 0 eur\n\nrule can_checkout:\n  yes\n  unless final_fee > 10 eur then no\n";