[Ur] css_style and 'Anonymous function remains at code generation'

Sergey Mironov grrwlf at gmail.com
Fri Oct 4 15:26:21 EDT 2013


> 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.

Thanks, that is clear. Is that 'mkcss' approach the only way to
synthesize css styles? I'm going to store heights/widths of images in
the database, that is why I need the way to tweak some styles
dynamically. I already have the code which does it using javascript
FFI but that method is not what I'd like to see in the end.

> 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].

Could you please recommend some reading covering the translation of
functional languages into imperative ones? My knowledge on this topic
is too small, I'd like to learn how we deal with first-class functions
when building C code.

Regards,
Sergey



More information about the Ur mailing list