lib.bend checks
raw source on the hub · import 0xcc241f125bd10140bf0de054c2512463/lib.bend as Lib
Stack — foundational LIFO stack for Bend. Publish entry for this package. Depends only on Base (does not reimplement List).
Encoding: a thin wrapper over List with the top at the list head. to_list is top-first (list head = stack top), not bottom-first. Quantity: Stack<a, A> is Kind(a), same convention as List/Maybe.
1 import
import Base
Types
type Stack source · line 9 · raw
@-a:Quant -> @-A:Kind(a) -> Kind(a)
S@-a:Quant -> @-A:Kind(a) -> @data:List<a, A> -> Stack<a, A>
type Stack.Pop source · line 13 · raw
@-a:Quant -> @-A:Kind(a) -> Kind(a)
Pop view: head + remaining stack.
HD@-a:Quant -> @-A:Kind(a) -> @head:A -> @rest:Stack<a, A> -> Stack.Pop<a, A>
Definitions
def Stack.empty source · line 16 · raw
@-a:Quant -> @-A:Kind(a) -> Stack<a, A>
def Stack.push source · line 19 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> @x:A -> Stack<a, A>
def Stack.pop.go source · line 24 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Maybe<a, Stack.Pop<a, A>>
def Stack.pop source · line 33 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Maybe<a, Stack.Pop<a, A>>
def Stack.peek.go source · line 36 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Maybe<a, A>
def Stack.peek source · line 45 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Maybe<a, A>
def Stack.is_empty source · line 48 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Bool
def Stack.length source · line 53 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> Nat
def Stack.to_list source · line 58 · raw
@-a:Quant -> @-A:Kind(a) -> @s:Stack<a, A> -> List<a, A>
def Stack.from_list source · line 63 · raw
@-a:Quant -> @-A:Kind(a) -> @xs:List<a, A> -> Stack<a, A>