view Paper/src/AgdaInterface.agda @ 3:576637483425

fix section, source code,etc
author ryokka
date Thu, 19 Apr 2018 20:28:12 +0900
parents bf2887cd22c1
children 4312a27022d1
line wrap: on
line source

data Maybe {n : Level } (a : Set n) : Set n where
  Nothing : Maybe a
  Just    : a -> Maybe a

record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.⊔ n) where
  field
    push : stackImpl -> a -> (stackImpl -> t) -> t
    pop  : stackImpl -> (stackImpl -> Maybe a -> t) -> t
    get  : stackImpl -> (stackImpl -> Maybe a -> t) -> t
open StackMethods

record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.⊔ n) where
  field
    stack : si
    stackMethods : StackMethods {n} {m} a {t} si
  pushStack :  a -> (Stack a si -> t) -> t
  pushStack d next = push (stackMethods ) (stack ) d (\s1 -> next (record {stack = s1 ; stackMethods = stackMethods } ))
  popStack : (Stack a si -> Maybe a  -> t) -> t
  popStack next = pop (stackMethods ) (stack ) (\s1 d1 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 )
  getStack :  (Stack a si -> Maybe a  -> t) -> t
  getStack next = get (stackMethods ) (stack ) (\s1 d1 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 )
open Stack