9811e6af63b652bf0f809a6b48056bb09560983f
[clean-tests.git] / afp / a12 / cashModel.dcl
1 definition module cashModel
2 /*
3 Pieter Koopman, Radboud University, 2017 -2018
4 pieter@cs.ru.nl
5 Advanced programming
6
7 A simple state model for an automated cash register
8 */
9
10 import StdEnv, Data.GenEq
11
12 :: Euro = {euro :: Int, cent :: Int}
13 :: Product = Pizza | Beer | Cola
14 :: Action = Add Product | Rem Product | Pay
15
16 class euro a :: a -> Euro
17 instance euro Product, Euro
18 instance euro Int, (Int, Int), [e] | euro e
19 instance + Euro
20 instance - Euro
21 instance zero Euro
22 derive gEq Euro
23 instance ~ Euro
24 instance == Euro, Product
25
26 model :: [Product] Action -> ([Product],[Euro])