[Ur] typing bind
Gergely Buday
gbuday at gmail.com
Thu Aug 18 09:57:37 EDT 2011
> The situation is exactly the same as in Haskell. The key is that [src <-
> source 0] by itself is not an expression. Rather, the holistic form [x <-
> e1; e2] is shorthand for [bind e1 (fn x => e2)].
Thanks. Now, keeping track of typing in increment.ur:
sequence seq
fun increment () = nextval seq
fun main () =
src <- source 0;
return <xml><body>
<dyn signal={n <- signal src; return <xml>{[n]}</xml>}/>
<button value="Update" onclick={n <- rpc (increment ()); set src n}/>
</body></xml>
src <- source 0 ; return <xml> is a shorthand for
bind (source 0) (fn src => return xml) whose type is
(m t1 -> (t1 -> m t2) -> m t2) (source int) (int -> transaction xml) =
transaction xml
and, src has type int.
But in n <- signal src; return <xml>{[n]}</xml> where
signal : source t -> signal t
the signal function expects a source int, not an int. What is wrong
with this line of thought?
- Gergely
More information about the Ur
mailing list