comparison tests/foldm.lac @ 75:88ffb3d61817

Folding through a functor
author Adam Chlipala <adamc@hcoop.net>
date Thu, 26 Jun 2008 12:35:26 -0400
parents
children
comparison
equal deleted inserted replaced
74:144d082b47ae 75:88ffb3d61817
1 con currier = fold (fn nm => fn t => fn acc => t -> acc) {}
2
3 signature S = sig
4 type t
5 val x : t
6
7 con rs :: {Type}
8 val create : currier rs -> t
9 end
10
11 functor Currier (M : sig con rs :: {Type} end) : S where con rs = M.rs = struct
12 val currier : rs :: {Type} -> currier rs =
13 fold [currier] (fn nm :: Name => fn t :: Type => fn rest :: {Type} => fn acc => fn x : t => acc) {}
14
15 type t = currier M.rs
16 val x = currier [M.rs]
17
18 con rs = M.rs
19 val create : t -> t = fn x => x
20 end
21
22 structure ChefsSpecial = Currier(struct
23 con rs = [A = int, B = float]
24 end)
25
26 val main = ChefsSpecial.x