playground/sml/comb.sml

20 lines
337 B
Standard ML

datatype 'a K
= C of 'a kcons
| P of 'a kprod
and 'a kcons
= B of 'a * ('a K) list * ('a K) list
| H of bool
and 'a kprod
= M of 'a * ('a K) list
| F of ('a K) list
(* sem: 'a K -> 'a kcons *)
fun sem (C c) = c
| sem (P p) =
case p of
M (a, kns) => B a (P (M (a, kns))) kns
| F ks => F ks