@@ -13,13 +13,14 @@ import Data.Foldable (foldMap, sum)
13
13
import Data.Int (toNumber , round )
14
14
import Data.Traversable (traverse )
15
15
import Data.Date (canonicalDate , diff )
16
- import Data.Time.Duration (unDays )
16
+ import Data.Time.Duration (Days (..))
17
+ import Data.Newtype (un )
17
18
import Math (pow , sin , cos , pi , abs )
18
19
19
20
import DOM (DOM )
20
21
import Signal.Channel (CHANNEL )
21
22
import Graphics.Canvas (CANVAS )
22
- import Control.Timer (TIMER )
23
+ import Control.Monad.Eff. Timer (TIMER )
23
24
24
25
import Signal.DOM (animationFrame )
25
26
import Signal.Time (since )
@@ -141,12 +142,12 @@ ui11 = foldp (+) 0 (button "Increment" 0 1)
141
142
142
143
-- Example 12
143
144
144
- table :: Int -> Int -> H.Markup
145
+ table :: forall e . Int -> Int -> H.Markup e
145
146
table h w = H .table $ foldMap row (0 .. h)
146
147
where row i = H .tr $ foldMap (cell i) (0 .. w)
147
148
cell i j = H .td (H .text (show i <> " ," <> show j))
148
149
149
- ui12 :: forall e . UI e H.Markup
150
+ ui12 :: forall e e' . UI e ( H.Markup e' )
150
151
ui12 = table <$> intSlider_ 0 9 5 <*> intSlider_ 0 9 5
151
152
152
153
-- Example 13
@@ -157,7 +158,7 @@ actions = string "Add item:" "Orange" <**> button "Add" (flip const) cons
157
158
list :: forall e . UI e (Array String )
158
159
list = foldp id [" Apple" , " Banana" ] actions
159
160
160
- ui13 :: forall e . UI e H.Markup
161
+ ui13 :: forall e e' . UI e ( H.Markup e' )
161
162
ui13 = (H .ul <<< foldMap (H .li <<< H .text)) <$> list
162
163
163
164
-- Example 14
@@ -168,7 +169,7 @@ showDomain :: Domain -> String
168
169
showDomain HSL = " HSL"
169
170
showDomain RGB = " RGB"
170
171
171
- toHTML :: Color -> H.Markup
172
+ toHTML :: forall e . Color -> H.Markup e
172
173
toHTML c = H .div `H.with` (A .style $ " background-color:" <> hex) $ H .text hex
173
174
where hex = cssStringHSLA c
174
175
@@ -214,12 +215,12 @@ ui15 = foldp (maybe id perform) 0 $
214
215
215
216
-- Example 16
216
217
217
- light :: Boolean -> H.Markup
218
+ light :: forall e . Boolean -> H.Markup e
218
219
light on = H .with H .div arg mempty
219
220
where arg | on = A .className " on"
220
221
| otherwise = mempty
221
222
222
- ui16 :: forall e . UI e H.Markup
223
+ ui16 :: forall e e' . UI e ( H.Markup e' )
223
224
ui16 = light <$> liftSF (since 1000.0 ) (button " Switch on" unit unit)
224
225
225
226
-- Example 17
@@ -230,7 +231,7 @@ ui17 = showDiff <$> date "Date 1" (fromMaybe bottom date1)
230
231
where
231
232
date1 = canonicalDate <$> toEnum 1986 <*> toEnum 7 <*> toEnum 3
232
233
date2 = canonicalDate <$> toEnum 2016 <*> toEnum 8 <*> toEnum 5
233
- showDiff d1 d2 = " Days between the dates: " <> show (round $ abs $ unDays $ diff d1 d2)
234
+ showDiff d1 d2 = " Days between the dates: " <> show (round $ abs $ un Days $ diff d1 d2)
234
235
235
236
236
237
-- Render everything to the DOM
0 commit comments