view forms.ur @ 32:d32fb0f7b137

Update for Ur/Web's new type class handling
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 Jul 2012 12:28:46 -0400
parents 5905b56e0cd9
children
line wrap: on
line source
datatype readiness a = Ready of a | Waiting | Invalid of string
datatype rpcResult a = Success of a | Failure of string

fun warning [a] (s : signal (readiness a)) =
    <xml><dyn signal={v <- s;
                      return (case v of
                                  Invalid s => <xml><b>{[s]}</b></xml>
                                | _ => <xml/>)}/></xml>

fun warningFmt [a ::: Type] [ctx ::: {Unit}] [ctx ~ [Dyn]] 
               (wrap : string -> xml ([Dyn] ++ ctx) [] []) 
               (s : signal (readiness a)) =
    <xml><dyn signal={v <- s;
                      return (case v of
                                  Invalid s => wrap s
                                | _ => <xml/>)}/></xml>