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

Commit

Permalink
Updates for 0.12 compiler (#38)
Browse files Browse the repository at this point in the history
* Updates for 0.12 compiler

* Remove event example
  • Loading branch information
paf31 authored Jun 24, 2018
1 parent d977905 commit f55fd95
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 658 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# purescript-behaviors

- [Example](test/Main.purs)
- [Moving Gears Example](https://github.com/knaman2609/purescript-behaviors-example)
- [Demo](https://github.com/paf31/purescript-behaviors-demo)
- [API Documentation](generated-docs/FRP)
- [Try `purescript-behaviors` in the browser](http://try.purescript.org/?backend=behaviors)
Expand Down
8 changes: 6 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
"purescript-effect": "^2.0.0",
"purescript-ordered-collections": "^1.0.0",
"purescript-filterable": "^3.0.0",
"purescript-nullable": "^4.0.0"
"purescript-nullable": "^4.0.0",
"purescript-event": "^1.2.4",
"purescript-web-html": "^1.0.0",
"purescript-web-events": "^1.0.0",
"purescript-web-uievents": "^1.0.0"
},
"devDependencies": {
"purescript-math": "^2.1.1",
"purescript-integers": "^4.0.0",
"purescript-drawing": "justinwoo/purescript-drawing#compiler/0.12"
"purescript-drawing": "^4.0.0"
}
}
1 change: 0 additions & 1 deletion src/FRP.purs

This file was deleted.

2 changes: 1 addition & 1 deletion src/FRP/Behavior.purs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Data.Function (applyFlipped)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(Tuple))
import FRP.Event (class IsEvent, Event, fix, fold, keepLatest, sampleOn, subscribe, withLast)
import FRP.Event.Time (animationFrame)
import FRP.Event.AnimationFrame (animationFrame)

-- | `ABehavior` is the more general type of `Behavior`, which is parameterized
-- | over some underlying `event` type.
Expand Down
10 changes: 5 additions & 5 deletions src/FRP/Behavior/Keyboard.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import Prelude

import Data.Set as Set
import FRP.Behavior (Behavior, behavior)
import FRP.Event.Keyboard (withKeys)
import FRP.Event.Keyboard (Keyboard, withKeys)

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

-- | A `Behavior` which reports whether a specific key is currently pressed.
key :: Int -> Behavior Boolean
key k = Set.member k <$> keys
key :: Keyboard -> String -> Behavior Boolean
key keyboard k = Set.member k <$> keys keyboard
11 changes: 5 additions & 6 deletions src/FRP/Behavior/Mouse.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ module FRP.Behavior.Mouse
import Prelude

import Data.Maybe (Maybe)
import Data.Nullable (toMaybe)
import Data.Set as Set
import FRP.Behavior (Behavior, behavior)
import FRP.Event.Mouse (withPosition, withButtons)
import FRP.Event.Mouse (Mouse, withPosition, withButtons)

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

-- | A `Behavior` which reports the mouse buttons which are currently pressed.
buttons :: Behavior (Set.Set Int)
buttons = behavior \e -> map (\{ value, buttons: bs } -> value (Set.fromFoldable bs)) (withButtons e)
buttons :: Mouse -> Behavior (Set.Set Int)
buttons m = behavior \e -> map (\{ value, buttons: bs } -> value bs) (withButtons m e)
12 changes: 7 additions & 5 deletions src/FRP/Behavior/Time.purs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
module FRP.Behavior.Time
( millisSinceEpoch
( instant
, seconds
) where

import Prelude

import Data.DateTime.Instant (Instant, unInstant)
import Data.Time.Duration (Seconds, toDuration)
import FRP.Behavior (Behavior, behavior)
import FRP.Event.Time (withTime)

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

-- | Get the current time in seconds since the epoch.
seconds :: Behavior Number
seconds = map (_ / 1000.0) millisSinceEpoch
seconds :: Behavior Seconds
seconds = map (toDuration <<< unInstant) instant
185 changes: 0 additions & 185 deletions src/FRP/Event.js

This file was deleted.

Loading

0 comments on commit f55fd95

Please sign in to comment.