[Ur] java-script calls are optimised out

Sergey Mironov grrwlf at gmail.com
Thu Oct 3 13:40:55 EDT 2013


Oh, yes, Thanks! I should have read the manual more carefully.
benignEffectful helped me. Still, the contract looks unusual (after IO
of Haskell). Did you think about including part of the contract in the
type signatures? I mean that we probably could have transaction monad
parametrized with some type indicating 'effectfulness'.

By the way, here is another idea of this kind, bothering me since I
started to explore Ur: can (should) we actually parametrize the
transaction monad with the 'side' type indicating server-side,
client-side or  'any side' ? Currently, programmer should keep the
side in mind, `alert' is the example (it has `transaction unit' type,
still we should not call it from the server side context). If we
lifted this information to the type annotations, we would then have

type client_side
type server_side

val alert : string -> transaction client_side unit
val getServerEnv : string -> transaction server_side (option string)

(* should work on both server and client sides *)
val debug : t ::: Type -> string -> transaction t unit

AFAIK the compiler already keeps all distinctions of this kind
internally! So what can go wrong with this?

Regards,
Sergey

2013/10/2 Adam Chlipala <adamc at csail.mit.edu>:
> On 10/02/2013 09:45 AM, Sergey Mironov wrote:
>>
>> I've encountered another problem, this time it looks bigger one.
>>
>> I have two FFIed javascript functions like
>>
>> val init1 : css_class ->  transaction unit
>> val init2 : css_class ->  transaction unit
>>
>> When I try to call both of them from onload, but only one is called
>> (the second one)
>>
>
>
> Have you marked them both as 'effectful' or 'benignEffectful' in your .urp
> file?  If not, the contract with the compiler is that calls may be
> "optimized" out.



More information about the Ur mailing list