Mercurial > hg > Papers > 2018 > ryokka-thesis
view final_pre/src/AgdaPushPop.agda @ 7:28f900230c26
add final_pre
author | ryokka |
---|---|
date | Mon, 19 Feb 2018 23:32:24 +0900 |
parents | |
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