Open
Description
Let's say I have the following contracts
Contract Alkohol, Underaged => String
def sell(drink, person)
"Sorry, come back in #{18 - person.age} years."
end
Contract Drink, Person => String
def sell(drink, person)
"Here's your #{drink}."
end
It works perfectly well, but let's say I want to define the sell
method on Person
. Now it becomes not obvious how would I check if the person is allowed to have the drink.
I propose to have some sort of self constraints. In Haskell-like syntax it would be
Contract :: (Underaged self) => Drink -> String