annotate tests/foldm.ur @ 418:ad7e854a518c

Metaform demos, minus prose
author Adam Chlipala <adamc@hcoop.net>
date Thu, 23 Oct 2008 14:03:12 -0400
parents 71bafe66dbe1
children
rev   line source
adamc@75 1 con currier = fold (fn nm => fn t => fn acc => t -> acc) {}
adamc@75 2
adamc@75 3 signature S = sig
adamc@75 4 type t
adamc@75 5 val x : t
adamc@75 6
adamc@75 7 con rs :: {Type}
adamc@75 8 val create : currier rs -> t
adamc@75 9 end
adamc@75 10
adamc@75 11 functor Currier (M : sig con rs :: {Type} end) : S where con rs = M.rs = struct
adamc@75 12 val currier : rs :: {Type} -> currier rs =
adamc@75 13 fold [currier] (fn nm :: Name => fn t :: Type => fn rest :: {Type} => fn acc => fn x : t => acc) {}
adamc@75 14
adamc@75 15 type t = currier M.rs
adamc@75 16 val x = currier [M.rs]
adamc@75 17
adamc@75 18 con rs = M.rs
adamc@75 19 val create : t -> t = fn x => x
adamc@75 20 end
adamc@75 21
adamc@75 22 structure ChefsSpecial = Currier(struct
adamc@75 23 con rs = [A = int, B = float]
adamc@75 24 end)
adamc@75 25
adamc@75 26 val main = ChefsSpecial.x