Mercurial > hg > Papers > 2021 > soto-thesis
view prepaper/src/AgdaPushPop.agda @ 14:a63df15c9afc default tip
DONE
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 15 Feb 2021 23:36:39 +0900 |
parents | 3dba680da508 |
children |
line wrap: on
line source
pushSingleLinkedStack : Meta -> Meta pushSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (push s e) }) where n = Meta.nextCS m s = Meta.stack m e = Context.element (Meta.context m) push : SingleLinkedStack A -> Maybe A -> SingleLinkedStack A push s nothing = s push s (just x) = record {top = just (cons x (top s))} popSingleLinkedStack : Meta -> Meta popSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (st m) ; context = record con {element = (elem m)}}) where n = Meta.nextCS m con = Meta.context m elem : Meta -> Maybe A elem record {stack = record { top = (just (cons x _)) }} = just x elem record {stack = record { top = nothing }} = nothing st : Meta -> SingleLinkedStack A st record {stack = record { top = (just (cons _ s)) }} = record {top = s} st record {stack = record { top = nothing }} = record {top = nothing} pushSingleLinkedStackCS : M.CodeSegment Meta Meta pushSingleLinkedStackCS = M.cs pushSingleLinkedStack popSingleLinkedStackCS : M.CodeSegment Meta Meta popSingleLinkedStackCS = M.cs popSingleLinkedStack