(*Domain Model in F#*) open System module Items = type ItemId = ItemId of string type Item = { Id : ItemId } let create id = { Id = ItemId id } module Boxes = open Items type BoxId = BoxId of string type Box = { Id : BoxId ; Items : Item list } let create id = { Id = BoxId id ; Items = [] } let addItem box item = { box with Items = box . Items @ [ item ] } let lines box = (*представление коробки /только чтение/*) let ( BoxId id ) = box . Id let head = sprintf "Корзина \"%s\" содержит:\n" id box . Items |> List . sort |> List . fold ( fun s item -> let ( ItemId id ) = item . Id s + ( sprintf "%s\n" id )) head [< EntryPoint >] let main argv = let box = Boxes . create "Желтая коробка" let box = Boxes . addItem box ( Items . create "Колбаса" ) ...
t.me/perfect0sight