Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit a412112

Browse files
committed
Fix example code
1 parent e54a706 commit a412112

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

example/src/Main.purs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ import Control.Monad.Error.Class (class MonadError)
66
import Data.Bitraversable (bitraverse)
77
import Data.Date (Date, canonicalDate)
88
import Data.DateTime (DateTime(..))
9-
import Data.Either (Either(..), either, fromRight)
9+
import Data.Either (Either(..), either, fromRight')
1010
import Data.Enum (class BoundedEnum, toEnum)
1111
import Data.Foldable (fold)
1212
import Data.Formatter.Interval (unformatInterval)
1313
import Data.Interval (Interval(..))
1414
import Data.Interval as I
1515
import Data.Interval.Duration.Iso (IsoDuration, mkIsoDuration)
1616
import Data.Map (Map, lookup, insert)
17+
import Data.Map as Map
1718
import Data.Maybe (Maybe(..), fromJust)
1819
import Data.Maybe.Last (Last(..))
19-
import Data.Symbol (class IsSymbol, SProxy(..))
20+
import Data.Symbol (class IsSymbol)
2021
import Data.Time (Time, setHour, setMinute)
2122
import Effect (Effect)
2223
import Effect.Exception as Ex
@@ -38,8 +39,9 @@ import Halogen.Datepicker.Internal.Utils (mustBeMounted)
3839
import Halogen.HTML as HH
3940
import Halogen.HTML.Events as HE
4041
import Halogen.VDom.Driver (runUI)
41-
import Partial.Unsafe (unsafePartial)
42+
import Partial.Unsafe (unsafeCrashWith, unsafePartial)
4243
import Prim.Row as Row
44+
import Type.Proxy (Proxy(..))
4345

4446
type TimeIdx = Int
4547
type DateIdx = Int
@@ -110,11 +112,11 @@ example =
110112
}
111113
where
112114
initialState =
113-
{ times: mempty
114-
, dates: mempty
115-
, dateTimes: mempty
116-
, durations: mempty
117-
, intervals: mempty
115+
{ times: Map.empty
116+
, dates: Map.empty
117+
, dateTimes: Map.empty
118+
, durations: Map.empty
119+
, intervals: Map.empty
118120
}
119121
render State HTML m
120122
render s = HH.div_
@@ -201,7 +203,7 @@ example =
201203
testDateTime = DateTime testDate (bottom # setHour (enum 2) # setMinute (enum 2))
202204

203205
testDuration IsoDuration
204-
testDuration = unsafePartial fromRight -- this duration must be valid
206+
testDuration = fromRight' (unsafeCrashWith "testDuration is an invalid IsoDuration")
205207
$ mkIsoDuration
206208
$ fold
207209
[ I.year 100.0
@@ -276,15 +278,15 @@ type ExampleConfig fmtInput input fmt query out m =
276278
, unformat fmt String StrOr input
277279
, picker fmt H.Component query Unit out m
278280
, handler Int out Action
279-
, setter Int Maybe input Action
281+
, setter Int Maybe input Action
280282
}
281283

282284
renderExample
283285
fmtInput input fmt sym query out px m
284286
. Row.Cons sym (H.Slot query out Int) px Slots
285287
IsSymbol sym
286288
ExampleConfig fmtInput input fmt query out m
287-
SProxy sym
289+
Proxy sym
288290
Map Int String
289291
Int
290292
fmtInput
@@ -295,7 +297,7 @@ renderExample c sp items idx fmt' value'= unEither $ do
295297
value ← either (c.unformat fmt) Right value'
296298
let cmp = c.picker fmt
297299
pure
298-
[ HH.slot sp idx cmp unit (Just <<< c.handler idx)
300+
[ HH.slot sp idx cmp unit (c.handler idx)
299301
, btn (Just value) "reset"
300302
, btn Nothing "clear"
301303
, case lookup idx items of
@@ -305,7 +307,7 @@ renderExample c sp items idx fmt' value'= unEither $ do
305307
where
306308
btn Maybe input String HTML m
307309
btn val txt = HH.button
308-
[ HE.onClick \_ → Just (c.setter idx val) ]
310+
[ HE.onClick \_ → c.setter idx val ]
309311
[ HH.text txt]
310312
unEither StrOr (Array (HTML m)) Array (HTML m)
311313
unEither = either (HH.text >>> pure >>> HH.div_ >>> pure) identity

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"devDependencies": {
99
"pulp": "^15.0.0",
10-
"purescript": "0.14.1",
10+
"purescript": "^0.14.1",
1111
"purescript-psa": "^0.8.2"
1212
}
1313
}

0 commit comments

Comments
 (0)