Mercurial > urweb
annotate demo/tcSum.ur @ 495:98f85c1bc867
Fix type calculation for applying-a-case optimization
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 11 Nov 2008 20:24:55 -0500 |
parents | e0e9e9eca1cb |
children | 6c4643880df5 |
rev | line source |
---|---|
adamc@417 | 1 fun sum (t ::: Type) (_ : num t) (fs ::: {Unit}) (x : $(mapUT t fs)) = |
adamc@417 | 2 foldUR [t] [fn _ => t] |
adamc@417 | 3 (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc) |
adamc@417 | 4 zero [fs] x |
adamc@417 | 5 |
adamc@417 | 6 fun main () = return <xml><body> |
adamc@417 | 7 {[sum {A = 0, B = 1}]}<br/> |
adamc@417 | 8 {[sum {C = 2.1, D = 3.2, E = 4.3}]} |
adamc@417 | 9 </body></xml> |