Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit f55fd95

Browse files
authored
Updates for 0.12 compiler (#38)
* Updates for 0.12 compiler * Remove event example
1 parent d977905 commit f55fd95

File tree

19 files changed

+222
-658
lines changed

19 files changed

+222
-658
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# purescript-behaviors
22

33
- [Example](test/Main.purs)
4-
- [Moving Gears Example](https://github.com/knaman2609/purescript-behaviors-example)
54
- [Demo](https://github.com/paf31/purescript-behaviors-demo)
65
- [API Documentation](generated-docs/FRP)
76
- [Try `purescript-behaviors` in the browser](http://try.purescript.org/?backend=behaviors)

bower.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@
2626
"purescript-effect": "^2.0.0",
2727
"purescript-ordered-collections": "^1.0.0",
2828
"purescript-filterable": "^3.0.0",
29-
"purescript-nullable": "^4.0.0"
29+
"purescript-nullable": "^4.0.0",
30+
"purescript-event": "^1.2.4",
31+
"purescript-web-html": "^1.0.0",
32+
"purescript-web-events": "^1.0.0",
33+
"purescript-web-uievents": "^1.0.0"
3034
},
3135
"devDependencies": {
3236
"purescript-math": "^2.1.1",
3337
"purescript-integers": "^4.0.0",
34-
"purescript-drawing": "justinwoo/purescript-drawing#compiler/0.12"
38+
"purescript-drawing": "^4.0.0"
3539
}
3640
}

src/FRP.purs

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/FRP/Behavior.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import Data.Function (applyFlipped)
3232
import Data.Maybe (Maybe(..))
3333
import Data.Tuple (Tuple(Tuple))
3434
import FRP.Event (class IsEvent, Event, fix, fold, keepLatest, sampleOn, subscribe, withLast)
35-
import FRP.Event.Time (animationFrame)
35+
import FRP.Event.AnimationFrame (animationFrame)
3636

3737
-- | `ABehavior` is the more general type of `Behavior`, which is parameterized
3838
-- | over some underlying `event` type.

src/FRP/Behavior/Keyboard.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import Prelude
77

88
import Data.Set as Set
99
import FRP.Behavior (Behavior, behavior)
10-
import FRP.Event.Keyboard (withKeys)
10+
import FRP.Event.Keyboard (Keyboard, withKeys)
1111

1212
-- | A `Behavior` which reports the keys which are currently pressed.
13-
keys :: Behavior (Set.Set Int)
14-
keys = behavior \e -> map (\{ value, keys: ks } -> value (Set.fromFoldable ks)) (withKeys e)
13+
keys :: Keyboard -> Behavior (Set.Set String)
14+
keys keyboard = behavior \e -> map (\{ value, keys: ks } -> value (Set.fromFoldable ks)) (withKeys keyboard e)
1515

1616
-- | A `Behavior` which reports whether a specific key is currently pressed.
17-
key :: Int -> Behavior Boolean
18-
key k = Set.member k <$> keys
17+
key :: Keyboard -> String -> Behavior Boolean
18+
key keyboard k = Set.member k <$> keys keyboard

src/FRP/Behavior/Mouse.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ module FRP.Behavior.Mouse
66
import Prelude
77

88
import Data.Maybe (Maybe)
9-
import Data.Nullable (toMaybe)
109
import Data.Set as Set
1110
import FRP.Behavior (Behavior, behavior)
12-
import FRP.Event.Mouse (withPosition, withButtons)
11+
import FRP.Event.Mouse (Mouse, withPosition, withButtons)
1312

1413
-- | A `Behavior` which reports the current mouse position, if it is known.
15-
position :: Behavior (Maybe { x :: Int, y :: Int })
16-
position = behavior \e -> map (\{ value, pos } -> value (toMaybe pos)) (withPosition e)
14+
position :: Mouse -> Behavior (Maybe { x :: Int, y :: Int })
15+
position m = behavior \e -> map (\{ value, pos } -> value pos) (withPosition m e)
1716

1817
-- | A `Behavior` which reports the mouse buttons which are currently pressed.
19-
buttons :: Behavior (Set.Set Int)
20-
buttons = behavior \e -> map (\{ value, buttons: bs } -> value (Set.fromFoldable bs)) (withButtons e)
18+
buttons :: Mouse -> Behavior (Set.Set Int)
19+
buttons m = behavior \e -> map (\{ value, buttons: bs } -> value bs) (withButtons m e)

src/FRP/Behavior/Time.purs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
module FRP.Behavior.Time
2-
( millisSinceEpoch
2+
( instant
33
, seconds
44
) where
55

66
import Prelude
77

8+
import Data.DateTime.Instant (Instant, unInstant)
9+
import Data.Time.Duration (Seconds, toDuration)
810
import FRP.Behavior (Behavior, behavior)
911
import FRP.Event.Time (withTime)
1012

1113
-- | Get the current time in milliseconds since the epoch.
12-
millisSinceEpoch :: Behavior Number
13-
millisSinceEpoch = behavior \e -> map (\{ value, time: t } -> value t) (withTime e)
14+
instant :: Behavior Instant
15+
instant = behavior \e -> map (\{ value, time: t } -> value t) (withTime e)
1416

1517
-- | Get the current time in seconds since the epoch.
16-
seconds :: Behavior Number
17-
seconds = map (_ / 1000.0) millisSinceEpoch
18+
seconds :: Behavior Seconds
19+
seconds = map (toDuration <<< unInstant) instant

src/FRP/Event.js

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)