Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-docgen

Documentation publishing for Pudu: articles, API references, navigation, search, and static websites

0.1.0Apache-2.01

InstallClose

Inventory.pudu

Pudu25 lines882 B

GitHub ↗
1/** @Samples.Inventory.Module — stock levels changed by receipts, sales, and counts */2module Inventory34// <types>5/** @Samples.Inventory.Item — one stock keeping unit and the quantity on hand */6export type Item = { sku: Str, quantity: Int }78/** @Samples.Inventory.Change — an event that changes the quantity of an item */9export type Change = Received(Int) | Sold(Int) | Counted(Int)10// </types>1112// <apply>13/// The item after a change: receipts add, sales remove, counts replace.14export fn apply(item: Item, change: Change) -> Item {15  match change {16    case Received(count) => Item{..item, quantity: item.quantity + count}17    case Sold(count) => Item{..item, quantity: item.quantity - count}18    case Counted(count) => Item{..item, quantity: count}19  }20}21// </apply>2223/// An item with nothing on hand.24export fn empty(sku: Str) -> Item { Item{sku: sku, quantity: 0} }25