Created
June 15, 2011 19:47
-
-
Save thoughtpolice/1027935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
con meta t = { Label : string | |
, Show : t -> string } | |
fun mkTable [r ::: {Type}] (fl : folder r) (mr : $(map meta r)) (x : $r) = | |
@fold [fn r => $(map meta r) -> $r -> xtable] | |
(fn [nm :: Name] [t :: Type] [r :: {Type}] [[nm] ~ r] acc mr x => | |
<xml><tr><th>{[ mr.nm.Label ]}</th><td> | |
{[ mr.nm.Show x.nm ]}</td></tr> | |
{ acc (mr -- nm) (x -- nm) } | |
</xml>) | |
(fn _ _ => <xml></xml>) fl mr x | |
fun main () = | |
let | |
val f = mkTable { A = { Label = "A", Show = @show show_int } | |
, B = { Label = "B", Show = @show show_float } | |
} | |
in | |
return <xml><body> | |
<table border=1>{f { A = 1, B = 1.2 }}</table> | |
</body></xml> | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment