2023-09-25 14:46:04 +00:00
|
|
|
(*
|
|
|
|
* SPDX-FileCopyrightText: 2023 Alain Zscheile <fogti+devel@ytrizja.de>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: CC0-1.0
|
|
|
|
*)
|
2023-09-24 21:58:28 +00:00
|
|
|
(* every object is basically a trait, just an interface *)
|
|
|
|
(* partial decomposition is possible *)
|
|
|
|
|
|
|
|
(* lets build a simple stack *)
|
|
|
|
|
|
|
|
λ $blti → {
|
|
|
|
|
2023-09-24 22:05:11 +00:00
|
|
|
pub let maybe = λ $T → data { :null; } λ $ →
|
2023-09-24 21:58:28 +00:00
|
|
|
.{ .none = blti.unitTy; .some = blti.boxTy T; };
|
|
|
|
|
|
|
|
let stack_ds = λ $T → μ $sdst → maybe (^{ T; sdst });
|
|
|
|
|
|
|
|
pub let stack = λ $T → {
|
|
|
|
let sdst = stack_ds T;
|
|
|
|
pub let nil = sdst.none blti.unit;
|
|
|
|
pub let push = λ $xs → λ $x →
|
|
|
|
sdst.some (blti.box .{ x; xs });
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|