]> gerrit.simantics Code Review - simantics/platform.git/blob - RecursiveContext.scl
9f8722cfd37dd4792ede40b362939c7b5c61ebb2
[simantics/platform.git] / RecursiveContext.scl
1 import "JavaBuiltin" as Java
2
3 infixl 6  (+), (-)
4
5 class Num a where 
6     (+) :: a -> a -> a
7     (-) :: a -> a -> a
8     isZero :: a -> Boolean
9     one :: a     
10     
11 instance Num Integer where
12     x + y = Java.iadd x y
13     x - y = Java.isub x y
14     isZero x = Java.icmpeq Java.iconst_0 x
15     one = Java.iconst_1
16   
17 even x = if isZero x then True else odd (x - one)
18 odd x = if isZero x then False else even (x - one)   
19     
20 main = odd (8 :: Integer)
21 --
22 false
23