Mercurial > hg > Members > atton > agda-proofs
changeset 13:14c22339ce06
Define state in agda
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 May 2016 16:01:54 +0900 |
parents | a59bebe0265a |
children | 31b1b7cc43cd |
files | state/state.agda |
diffstat | 1 files changed, 6 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/state/state.agda Fri Dec 11 20:27:04 2015 +0900 +++ b/state/state.agda Tue May 03 16:01:54 2016 +0900 @@ -15,28 +15,23 @@ module state where -record Product {l ll : Level} (A : Set l) (B : Set ll) : Set (suc (l ⊔ ll)) where +record Product {l : Level} (A B : Set l) : Set (suc l) where constructor <_,_> field first : A second : B open Product -product-create : {l ll : Level} {A : Set l} {B : Set ll} -> A -> B -> Product A B -product-create a b = < a , b > - - -record State {l ll : Level} (S : Set l) (A : Set ll) : Set (suc (l ⊔ ll)) where +record State {l : Level} (S A : Set l) : Set (suc l) where field runState : S -> Product A S open State -state : {l ll : Level} {S : Set l} {A : Set ll} -> (S -> Product A S) -> State S A +state : {l : Level} {S A : Set l} -> (S -> Product A S) -> State S A state f = record {runState = f} -return : {l ll : Level} {S : Set l} {A : Set ll} -> A -> State S A +return : {l : Level} {S A : Set l} -> A -> State S A return a = state (\s -> < a , s > ) - -_>>=_ : {l ll lll : Level} {S : Set l} {A : Set ll} {B : Set lll} -> State S A -> (A -> State S B) -> State S B -m >>= k = {!!} \ No newline at end of file +_>>=_ : {l : Level} {S A B : Set l} -> State S A -> (A -> State S B) -> State S B +m >>= k = state (\s -> (State.runState (k (Product.first (State.runState m s))) (Product.second (State.runState m s)))) \ No newline at end of file