adamc@151: con stringify = fold (fn nm :: Name => fn u :: Unit => fn t :: {Type} => [nm = string] ++ t) [] adamc@151: adamc@151: signature S = sig adamc@151: con rs :: {Unit} adamc@151: val names : $(stringify rs) adamc@151: end adamc@151: adamc@151: signature S' = sig adamc@151: con rs :: {Unit} adamc@151: adamc@151: val handler : $(stringify rs) -> page adamc@151: val page : unit -> page adamc@151: end adamc@151: adamc@151: functor F (M : S) : S' where con rs = M.rs = struct adamc@151: con rs = M.rs adamc@151: adamc@151: val handler = fn x : $(stringify M.rs) => adamc@151: {fold [fn rs :: {Unit} => $(stringify rs) -> $(stringify rs) -> xml body [] []] adamc@151: (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} => adamc@151: fn f : $(stringify rest) -> $(stringify rest) -> xml body [] [] => adamc@151: fn names : $(stringify ([nm] ++ rest)) => adamc@151: fn x : $(stringify ([nm] ++ rest)) => adamc@151:
  • {cdata names.nm}: {cdata x.nm}
  • {f (names -- nm) (x -- nm)}) adamc@151: (fn names => fn x => ) adamc@151: [M.rs] M.names x} adamc@151: adamc@151: adamc@151: val page = fn () => adamc@151: adamc@151: {fold [fn rs :: {Unit} => xml lform [] (stringify rs)] adamc@151: (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} => adamc@151: fn frag : xml lform [] (stringify rest) => adamc@151:
  • {useMore frag}
    ) adamc@151: adamc@151: [rs]} adamc@151: adamc@151: adamc@151:
    adamc@151: adamc@151: end adamc@151: adamc@151: structure M = F(struct adamc@151: con rs = [A, B, C] adamc@151: adamc@151: val names = {A = "A", B = "B", C = "C"} adamc@151: end) adamc@151: adamc@151: open M adamc@151: