代表分类帐数据结构



考虑到我的purescript程序包含代表可以交换的项目的不同类型,例如 VegetableMilkMeat等参与者之间的交流?为了简化我们可以将参与者表示为type Participant = Int

您可以使用purescript-variant进行打开总和。

type Ledger products = Array (Entry products)
type Entry products =
  { date ∷ DateTime
  , product ∷ Variant products
  , unitPrice ∷ Int
  , quantity ∷ Int
  }

然后可以针对一组特定产品进行实例化,例如Ledger (milk ∷ Milk, vegetable ∷ Vegetable, meat ∷ Meat)

最新更新