Ur/Web Examples
Check-in [9fe61fe278]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:tiny cleanups
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9fe61fe278276a42231076835f768bdcbc8c61fb
User & Date: beyert 2016-08-17 07:36:18
Context
2016-08-17
07:44
update copyright year Leaf check-in: 164b329722 user: beyert tags: trunk
07:36
tiny cleanups check-in: 9fe61fe278 user: beyert tags: trunk
07:33
further improve examples in composableSignals check-in: 598aee9f68 user: beyert tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to composableSignals/composableSignals.ur.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
                           (s3: signal c) : signal d =
  s1' <- s1;
  s2' <- s2;
  s3' <- s3;
  pure (f s1' s2' s3')

(* variations on the above functions with raw signals passed directly to (and
returned by) the function argument *)
fun mapS' [a] [b] (f: signal a -> signal b) (s: signal a) : signal b =
  f s

fun liftS' [a] [b] (f: signal a -> signal b) (s: signal a) : signal b =
  f s

fun liftS2' [a] [b] [c] (f: signal a -> signal b -> signal c) (s1: signal a)
................................................................................
                                   return (x * y)) (s srcX) (s srcY);
                   return <xml>{[x']}</xml>}/>
      <dyn signal={x' <- liftS3' (fn sx sy sz => x <- sx; y <- sy; z <- sz;
                                   return (x * y * z)) (s srcX) (s srcY)
                                 (s srcN);
                   return <xml>{[x']}</xml>}/>
      (* the next two examples use pure instead of return in the inner fn, to
      show that it also works, which may be preferable because it is more
      domain-specific, and more concise *)
      <dyn signal={s' <- liftS' (fn sx => x <- sx; pure (x + 1)) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS2' (fn sx sy => x <- sx; y <- sy;
                                  pure (x + y)) (pure 1) (s srcN);
                   return <xml>{[s']}</xml>}/>

      <h2>signal values: part two</h2>







|







 







|
|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
                           (s3: signal c) : signal d =
  s1' <- s1;
  s2' <- s2;
  s3' <- s3;
  pure (f s1' s2' s3')

(* variations on the above functions with raw signals passed directly to (and
   returned by) the function argument *)
fun mapS' [a] [b] (f: signal a -> signal b) (s: signal a) : signal b =
  f s

fun liftS' [a] [b] (f: signal a -> signal b) (s: signal a) : signal b =
  f s

fun liftS2' [a] [b] [c] (f: signal a -> signal b -> signal c) (s1: signal a)
................................................................................
                                   return (x * y)) (s srcX) (s srcY);
                   return <xml>{[x']}</xml>}/>
      <dyn signal={x' <- liftS3' (fn sx sy sz => x <- sx; y <- sy; z <- sz;
                                   return (x * y * z)) (s srcX) (s srcY)
                                 (s srcN);
                   return <xml>{[x']}</xml>}/>
      (* the next two examples use pure instead of return in the inner fn, to
         show that it also works, which may be preferable because it is more
         domain-specific, and more concise *)
      <dyn signal={s' <- liftS' (fn sx => x <- sx; pure (x + 1)) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS2' (fn sx sy => x <- sx; y <- sy;
                                  pure (x + y)) (pure 1) (s srcN);
                   return <xml>{[s']}</xml>}/>

      <h2>signal values: part two</h2>