On 10/04/2013 10:30 AM, Sergey Mironov wrote:
fun mkcss (n:string) (v:string) : (css_style ->  css_style) = fn x =>
oneProperty x (value (property n) (atom v))

fun css (l : list (css_style ->  css_style)) : css_style =
   List.foldr (fn f s =>  f s) noStyle l

This issue isn't directly related to CSS. Rather, in Ur/Web, no first-class functions are allowed to exist in server-side code at runtime. The compiler can't find a way to optimize your code to hide the first-class functions of type [css_style -> css_style], since there is currently no optimization to simplify calls to recursive functions (e.g., [foldr]) statically.

Two effective refactorings that come to mind are:
1. Fold over a record instead of a list.
2. Fold over a list of "(n, v) pairs" instead of a list of functions, calling [mkcss] within the first argument to [List.foldr].

_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to