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