Skip to content

Commit d198642

Browse files
authored
Updates for PureScript 0.10 (#20)
1 parent 9373124 commit d198642

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

bower.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
"url": "git://github.com/sharkdp/purescript-flare.git"
1717
},
1818
"dependencies": {
19-
"purescript-foldable-traversable": "^1.0.0",
20-
"purescript-dom": "^2.0.0",
21-
"purescript-signal": "^6.1.0",
22-
"purescript-canvas": "^1.0.0",
23-
"purescript-drawing": "^1.0.0",
24-
"purescript-smolder": "^4.0.0",
25-
"purescript-nonempty": "^1.0.0",
26-
"purescript-datetime": "^1.0.0"
19+
"purescript-foldable-traversable": "^2.0.0",
20+
"purescript-dom": "^3.0.0",
21+
"purescript-signal": "^8.0.0",
22+
"purescript-canvas": "^2.0.0",
23+
"purescript-drawing": "^2.0.0",
24+
"purescript-smolder": "^6.0.0",
25+
"purescript-nonempty": "^3.0.0",
26+
"purescript-datetime": "^2.0.0"
2727
}
2828
}

src/Flare.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ module Flare
5252
import Prelude
5353

5454
import Data.Array (fromFoldable)
55+
import Data.Newtype (unwrap)
5556
import Data.NonEmpty (NonEmpty, (:|))
5657
import Data.Maybe (Maybe(..), fromMaybe)
57-
import Data.Maybe.First (First(..), runFirst)
58+
import Data.Maybe.First (First(..))
5859
import Data.Monoid (class Monoid, mempty)
5960
import Data.Foldable (class Foldable, traverse_, foldMap)
6061
import Data.Traversable (class Traversable, traverse)
@@ -259,7 +260,7 @@ button label vDefault vPressed = createUI (cButton vPressed) label vDefault
259260
-- | component returns `Nothing` if none of the buttons is pressed and `Just x`
260261
-- | if the button corresponding to the element `x` is pressed.
261262
buttons :: forall f a e. Traversable f => f a -> (a -> String) -> UI e (Maybe a)
262-
buttons xs toString = (runFirst <<< foldMap First) <$> traverse toButton xs
263+
buttons xs toString = (unwrap <<< foldMap First) <$> traverse toButton xs
263264
where
264265
toButton :: forall eff. a -> UI eff (Maybe a)
265266
toButton x = button (toString x) Nothing (Just x)

src/Flare/Smolder.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import Flare (UI, ElementId, runFlare)
1616
-- | Renders a Flare UI with `Markup` as output. The first ID specifies
1717
-- | the DOM element for the controls while the second ID specifies the
1818
-- | element for the output.
19-
runFlareHTML :: forall e. ElementId
20-
-> ElementId
21-
-> UI e Markup
22-
-> Eff (dom :: DOM, channel :: CHANNEL | e) Unit
19+
runFlareHTML :: forall e e'. ElementId
20+
-> ElementId
21+
-> UI e (Markup e')
22+
-> Eff (dom :: DOM, channel :: CHANNEL | e) Unit
2323
runFlareHTML controls target =
2424
runFlare controls target <<< map render

test/Main.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import Data.Foldable (foldMap, sum)
1313
import Data.Int (toNumber, round)
1414
import Data.Traversable (traverse)
1515
import Data.Date (canonicalDate, diff)
16-
import Data.Time.Duration (unDays)
16+
import Data.Time.Duration (Days(..))
17+
import Data.Newtype (un)
1718
import Math (pow, sin, cos, pi, abs)
1819

1920
import DOM (DOM)
2021
import Signal.Channel (CHANNEL)
2122
import Graphics.Canvas (CANVAS)
22-
import Control.Timer (TIMER)
23+
import Control.Monad.Eff.Timer (TIMER)
2324

2425
import Signal.DOM (animationFrame)
2526
import Signal.Time (since)
@@ -141,12 +142,12 @@ ui11 = foldp (+) 0 (button "Increment" 0 1)
141142

142143
-- Example 12
143144

144-
table :: Int -> Int -> H.Markup
145+
table :: forall e. Int -> Int -> H.Markup e
145146
table h w = H.table $ foldMap row (0 .. h)
146147
where row i = H.tr $ foldMap (cell i) (0 .. w)
147148
cell i j = H.td (H.text (show i <> "," <> show j))
148149

149-
ui12 :: forall e. UI e H.Markup
150+
ui12 :: forall e e'. UI e (H.Markup e')
150151
ui12 = table <$> intSlider_ 0 9 5 <*> intSlider_ 0 9 5
151152

152153
-- Example 13
@@ -157,7 +158,7 @@ actions = string "Add item:" "Orange" <**> button "Add" (flip const) cons
157158
list :: forall e. UI e (Array String)
158159
list = foldp id ["Apple", "Banana"] actions
159160

160-
ui13 :: forall e. UI e H.Markup
161+
ui13 :: forall e e'. UI e (H.Markup e')
161162
ui13 = (H.ul <<< foldMap (H.li <<< H.text)) <$> list
162163

163164
-- Example 14
@@ -168,7 +169,7 @@ showDomain :: Domain -> String
168169
showDomain HSL = "HSL"
169170
showDomain RGB = "RGB"
170171

171-
toHTML :: Color -> H.Markup
172+
toHTML :: forall e. Color -> H.Markup e
172173
toHTML c = H.div `H.with` (A.style $ "background-color:" <> hex) $ H.text hex
173174
where hex = cssStringHSLA c
174175

@@ -214,12 +215,12 @@ ui15 = foldp (maybe id perform) 0 $
214215

215216
-- Example 16
216217

217-
light :: Boolean -> H.Markup
218+
light :: forall e. Boolean -> H.Markup e
218219
light on = H.with H.div arg mempty
219220
where arg | on = A.className "on"
220221
| otherwise = mempty
221222

222-
ui16 :: forall e. UI e H.Markup
223+
ui16 :: forall e e'. UI e (H.Markup e')
223224
ui16 = light <$> liftSF (since 1000.0) (button "Switch on" unit unit)
224225

225226
-- Example 17
@@ -230,7 +231,7 @@ ui17 = showDiff <$> date "Date 1" (fromMaybe bottom date1)
230231
where
231232
date1 = canonicalDate <$> toEnum 1986 <*> toEnum 7 <*> toEnum 3
232233
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)
234235

235236

236237
-- Render everything to the DOM

0 commit comments

Comments
 (0)