diff src/parallel_execution/RedBlackTree.agda @ 511:044c25475ed4

fix stack.agda
author mir3636
date Thu, 04 Jan 2018 14:42:21 +0900
parents 0223c07c3946
children 95865cab040a
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.agda	Wed Jan 03 18:22:38 2018 +0900
+++ b/src/parallel_execution/RedBlackTree.agda	Thu Jan 04 14:42:21 2018 +0900
@@ -1,23 +1,25 @@
 module RedBlackTree where
 
 open import stack
+open import Level
 
-record Tree {a t : Set} (treeImpl : Set) : Set  where
+record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
+  field
+    putImpl : treeImpl -> a -> (treeImpl -> t) -> t
+    getImpl  : treeImpl -> (treeImpl -> Maybe a -> t) -> t
+open TreeMethods
+
+record Tree  {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
   field
     tree : treeImpl
-    putImpl : treeImpl -> a -> (treeImpl -> t) -> t
-    getImpl  : treeImpl -> (treeImpl -> Maybe a -> t) -> t
+    treeMethods : TreeMethods {a} {t}
+  putTree : a -> (Tree -> t) -> t
+  putTree d next = putImpl (treeMethods ) tree d (\t1 -> next (record {tree = t1 ; treeMethods = treeMethods} ))
+  getTree : (Tree -> Maybe a -> t) -> t
+  getTree next = getImpl (treeMethods ) tree (\t1 d -> next (record {tree = t1 ; treeMethods = treeMethods} ) d )
 
 open Tree
 
-
-putTree : {a t : Set} -> Tree -> a -> (Tree -> t) -> t
-putTree {a} {t} t0 d next = (putImpl t0) (tree t0) d (\t1 -> next (record t0 {tree = t1} ))
-
-getTree : {a t : Set} -> Tree -> (Tree -> t) -> t
-getTree {a} {t} t0  next = (getImpl t0) (tree t0) (\t1 -> next t0)
-
-
 data Color : Set where
   Red   : Color
   Black : Color
@@ -29,10 +31,10 @@
     left  : Maybe (Node a)
     color : Color
 
-record RedBlackTree (a : Set) : Set where
+record RedBlackTree (a si : Set) : Set where
   field
     root : Maybe (Node a)
-    stack : Stack
+    stack : Stack si
 
 open RedBlackTree