spec base_employee
"""
Base Employee Page
Defines basic employee data that can be referenced and extended.
"""
uses lemma units
data department : "Engineering"
data employment_duration : units.calendar -> default 0 year
data is_full_time : true
data name : "John Doe"
data monthly_salary : number -> minimum 0 -> default 5_000
rule annual_salary:
monthly_salary * 12
rule is_eligible_for_bonus:
false
unless employment_duration >= 1 year then true
spec specific_employee
"""
Specific Employee Page
References the base employee spec and binds specific data.
Demonstrates spec composition, data binding, and rule references.
"""
uses employee: base_employee
with employee.employment_duration : 3 year
with employee.monthly_salary : 7_500
with employee.name : "Alice Smith"
rule salary_with_bonus:
employee.annual_salary
unless employee.is_eligible_for_bonus
then employee.annual_salary * 1.1
rule employee_summary:
employee.name
spec contractor
"""
Contractor Page
Shows a different employment model using spec references.
"""
uses lemma units
data money: quantity
-> unit eur 1.00
data wage_rate: quantity
-> unit eur_per_second eur/second
-> unit eur_per_hour eur/hour
data hours_worked : 120 hours
data hourly_rate : wage_rate -> minimum 0 eur_per_hour -> default 85 eur_per_hour
uses person: base_employee
with person.is_full_time : false
rule total_payment:
(hourly_rate * hours_worked) as eur
rule annual_hours:
hours_worked * 12
rule benefits_eligible:
false
unless annual_hours > 1_000 hours then true