-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExample.idr
52 lines (40 loc) · 968 Bytes
/
Example.idr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module Main
import Control.Monad.State
import Cairo
%foreign
"untupled:(_,_)"
"""
code:
func $name$(key, world) -> (world, result):
return (world, result=key)
end
"""
cairo_identityPrim : Felt -> PrimCairo Felt
cairo_identity : Felt -> Cairo Felt
cairo_identity val = fromPrimCairo (cairo_identityPrim val)
multiply : Felt -> Felt -> Felt
multiply a b = a * b
foo : State (Felt, Felt) Felt
foo = do
(current, acc) <- get
if current == 10
then pure acc
else do
put (current + 1, acc + current)
foo
pythag_check : Felt -> Felt -> Felt -> Bool
pythag_check a b c = (a * a + b * b) == (c * c)
main : Cairo ()
main = do
m1' <- cairo_identity 55
let m1 = multiply 20 m1'
let m2 = multiply 25 50
if m1 == m2
then output m1
else output m2
let pyth = pythag_check
if pyth 3 4 5
then output $ cast $ the Int32 20
else output 40
output $ pedersenHash 20 30
-- output $ evalState (0, 0) foo