Ur/Web Examples
Check-in [598aee9f68]
Not logged in

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

Overview
Comment:further improve examples in composableSignals
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:598aee9f687b30fce1bf9e433d456c05fe798d3f
User & Date: beyert 2016-08-17 07:33:39
Context
2016-08-17
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
07:23
in composableSignals, use better examples / make examples more consistent, particuarly showing that pure/return can be used as a constructor for signals check-in: 904ba75c5b user: beyert tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to composableSignals/composableSignals.ur.

79
80
81
82
83
84
85
86
87
88
89
90
91



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS' (fn sx => x <- sx; return (x + 1)) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={x' <- liftS2' (fn sx sy => x <- sx; y <- sy; return (x + y))
                                 (s srcX) (s srcY);
                   return <xml>{[x']}</xml>}/>
      <dyn signal={x' <- liftS2' (fn sx sy => x <- sx; y <- sy;
                                   pure (x * y)) (s srcX) (s srcY);
                   return <xml>{[x']}</xml>}/>
      <dyn signal={x' <- liftS3' (fn sx sy sz => x <- sx; y <- sy; z <- sz;
                                   pure (x * y * z)) (s srcX) (s srcY)
                                 (s srcN);
                   return <xml>{[x']}</xml>}/>



      <dyn signal={s' <- liftS' (fn sx => x <- sx; return (x + 1)) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS2' (fn sx sy => x <- sx; y <- sy;
                                  return (x + y)) (pure 1) (s srcN);
                   return <xml>{[s']}</xml>}/>

      <h2>signal values: part two</h2>
      <dyn signal={w' <- liftS2 (fn x y => x * y) (s srcX) (s srcY);
                   x' <- liftS (fn x => x * 2) (pure w');
                   y' <- liftS3 (fn x y z => x * y * z)
                                (pure w') (s srcX) (pure 3);
                   z' <- liftS (fn x => x + 11) (pure y');
                   return <xml>{[w']} {[x']} {[y']} {[z']}</xml>}/>
      <dyn signal={s' <- liftS (fn x => x + 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- mapS (fn x => x - 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS (fn x => x + 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS2 (fn x y => x + y) (pure 1) (pure 1);
                   return <xml>{[s']}</xml>}/>
    </body>
    </xml>







|


|


>
>
>
|


|






|












79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS' (fn sx => x <- sx; return (x + 1)) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={x' <- liftS2' (fn sx sy => x <- sx; y <- sy; return (x + y))
                                 (s srcX) (s srcY);
                   return <xml>{[x']}</xml>}/>
      <dyn signal={x' <- liftS2' (fn sx sy => x <- sx; y <- sy;
                                   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>
      <dyn signal={w' <- liftS2 (fn x y => x * y) (s srcX) (s srcY);
                   x' <- liftS (fn x => x * 2) (pure w');
                   y' <- liftS3 (fn x y z => x * y * z)
                                (pure w') (s srcX) (pure x');
                   z' <- liftS (fn x => x + 11) (pure y');
                   return <xml>{[w']} {[x']} {[y']} {[z']}</xml>}/>
      <dyn signal={s' <- liftS (fn x => x + 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- mapS (fn x => x - 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS (fn x => x + 1) (s srcN);
                   return <xml>{[s']}</xml>}/>
      <dyn signal={s' <- liftS2 (fn x y => x + y) (pure 1) (pure 1);
                   return <xml>{[s']}</xml>}/>
    </body>
    </xml>