annotate src/atton-master-sample.agda @ 1:73127e0ab57c

(none)
author soto@cr.ie.u-ryukyu.ac.jp
date Tue, 08 Sep 2020 18:38:08 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 module atton-master-sample where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 open import Data.Nat
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 open import Data.Unit
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 open import Function
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 Int = ℕ
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8 record Context : Set where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 a : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 b : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 c : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 open import subtype Context
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 record ds0 : Set where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 a : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 b : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 record ds1 : Set where
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 field
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 c : Int
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 instance
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 _ : DataSegment ds0
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 _ = record { set = (\c d -> record c {a = (ds0.a d) ; b = (ds0.b d)})
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 ; get = (\c -> record { a = (Context.a c) ; b = (Context.b c)})}
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 _ : DataSegment ds1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 _ = record { set = (\c d -> record c {c = (ds1.c d)})
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 ; get = (\c -> record { c = (Context.c c)})}
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 cs2 : CodeSegment ds1 ds1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 cs2 = cs id
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 cs1 : CodeSegment ds1 ds1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 cs1 = cs (\d -> goto cs2 d)
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 cs0 : CodeSegment ds0 ds1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 cs0 = cs (\d -> goto cs1 (record {c = (ds0.a d) + (ds0.b d)}))
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 main : ds1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 main = goto cs0 (record {a = 100 ; b = 50})