Yampa 0.10.6.2 → 0.10.7
raw patch · 17 files changed
+121/−33 lines, 17 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- FRP.Yampa.Point2: instance (GHC.Show.Show a, GHC.Float.RealFloat a) => GHC.Show.Show (FRP.Yampa.Point2.Point2 a)
- FRP.Yampa.Point2: instance GHC.Float.RealFloat a => GHC.Classes.Eq (FRP.Yampa.Point2.Point2 a)
- FRP.Yampa.Point3: instance GHC.Float.RealFloat a => GHC.Classes.Eq (FRP.Yampa.Point3.Point3 a)
- FRP.Yampa.Vector2: instance (GHC.Show.Show a, GHC.Float.RealFloat a) => GHC.Show.Show (FRP.Yampa.Vector2.Vector2 a)
- FRP.Yampa.Vector2: instance GHC.Float.RealFloat a => GHC.Classes.Eq (FRP.Yampa.Vector2.Vector2 a)
- FRP.Yampa.Vector3: instance (GHC.Show.Show a, GHC.Float.RealFloat a) => GHC.Show.Show (FRP.Yampa.Vector3.Vector3 a)
- FRP.Yampa.Vector3: instance GHC.Float.RealFloat a => GHC.Classes.Eq (FRP.Yampa.Vector3.Vector3 a)
+ FRP.Yampa: maybeToEvent :: Maybe a -> Event a
+ FRP.Yampa.Point2: instance GHC.Classes.Eq a => GHC.Classes.Eq (FRP.Yampa.Point2.Point2 a)
+ FRP.Yampa.Point2: instance GHC.Show.Show a => GHC.Show.Show (FRP.Yampa.Point2.Point2 a)
+ FRP.Yampa.Point3: instance GHC.Classes.Eq a => GHC.Classes.Eq (FRP.Yampa.Point3.Point3 a)
+ FRP.Yampa.Point3: instance GHC.Show.Show a => GHC.Show.Show (FRP.Yampa.Point3.Point3 a)
+ FRP.Yampa.Vector2: instance GHC.Classes.Eq a => GHC.Classes.Eq (FRP.Yampa.Vector2.Vector2 a)
+ FRP.Yampa.Vector2: instance GHC.Show.Show a => GHC.Show.Show (FRP.Yampa.Vector2.Vector2 a)
+ FRP.Yampa.Vector3: instance GHC.Classes.Eq a => GHC.Classes.Eq (FRP.Yampa.Vector3.Vector3 a)
+ FRP.Yampa.Vector3: instance GHC.Show.Show a => GHC.Show.Show (FRP.Yampa.Vector3.Vector3 a)
- FRP.Yampa.MergeableRecord: data MergeableRecord a => MR a
+ FRP.Yampa.MergeableRecord: data MR a
- FRP.Yampa.Point2: data RealFloat a => Point2 a
+ FRP.Yampa.Point2: data Point2 a
- FRP.Yampa.Point3: data RealFloat a => Point3 a
+ FRP.Yampa.Point3: data Point3 a
- FRP.Yampa.Vector2: data RealFloat a => Vector2 a
+ FRP.Yampa.Vector2: data Vector2 a
- FRP.Yampa.Vector3: data RealFloat a => Vector3 a
+ FRP.Yampa.Vector3: data Vector3 a
Files
- CHANGELOG +14/−0
- Yampa.cabal +8/−1
- examples/TailgatingDetector/TailgatingDetector.hs +2/−0
- examples/yampa-game/YampaSDL.hs +33/−0
- src/FRP/Yampa.hs +6/−5
- src/FRP/Yampa/Delays.hs +1/−2
- src/FRP/Yampa/Event.hs +31/−2
- src/FRP/Yampa/Hybrid.hs +0/−1
- src/FRP/Yampa/Integration.hs +0/−1
- src/FRP/Yampa/InternalCore.hs +1/−2
- src/FRP/Yampa/MergeableRecord.hs +1/−1
- src/FRP/Yampa/Point2.hs +6/−4
- src/FRP/Yampa/Point3.hs +6/−2
- src/FRP/Yampa/Time.hs +0/−1
- src/FRP/Yampa/Vector2.hs +6/−3
- src/FRP/Yampa/Vector3.hs +6/−3
- tests/AFRPTestsSscan.hs +0/−5
CHANGELOG view
@@ -1,3 +1,17 @@+2017-12-17 Ivan Perez <ivan.perez@keera.co.uk>+ * Yampa.cabal: Version bump (0.10.7), adds flag descriptions,+ fixes missing modules.+ * README.md: Adds images to descriptions.+ * doc/: New HCAR including iOS release.+ * src/: Exposes new function, removes unused extensions,+ simplifies code, adds documentation, fixes multiple bugs.+ * stack.yaml: Fixes nix setup.+ * tests/: Adapts to new API.+ * examples/: Adapts to new API.+ * Thanks to @chriz-keera, @suzumiyasmith, @meimisaki, + @RyanGlScott, @madjestic, @mgttlinger, @eapcochran, + @jonmouchou.+ 2017-08-28 Ivan Perez <ivan.perez@keera.co.uk> * Yampa.cabal: Version bump (0.10.6.2), fixes issue with dependencies. * stack.yaml: Includes minimal stack configuration.
Yampa.cabal view
@@ -1,5 +1,5 @@ name: Yampa-version: 0.10.6.2+version: 0.10.7 cabal-version: >= 1.8 license: BSD3 license-file: LICENSE@@ -36,20 +36,24 @@ -- You can disable the hlint test suite with -f-test-hlint flag test-hlint+ Description: Enable hlint test suite default: False manual: True -- You can disable the haddock coverage test suite with -f-test-doc-coverage flag test-doc-coverage+ Description: Enable haddock coverage test suite default: False manual: True -- You can disable the regression test suite with -f-test-regression flag test-regression+ Description: Enable regression test suite default: True manual: True flag examples+ Description: Enable examples default: False manual: True @@ -139,6 +143,7 @@ executable yampa-examples-sdl-bouncingbox main-is: MainBouncingBox.hs+ other-modules: YampaSDL hs-source-dirs: examples/yampa-game/ ghc-options : -O3 -Wall -fno-warn-name-shadowing if flag(examples)@@ -149,6 +154,7 @@ executable yampa-examples-sdl-circlingmouse main-is: MainCircleMouse.hs+ other-modules: YampaSDL hs-source-dirs: examples/yampa-game/ ghc-options : -O3 -Wall -fno-warn-name-shadowing if flag(examples)@@ -159,6 +165,7 @@ executable yampa-examples-sdl-wiimote main-is: MainWiimote.hs+ other-modules: YampaSDL hs-source-dirs: examples/yampa-game/ ghc-options : -O3 -Wall -fno-warn-name-shadowing -rtsopts if flag(examples)
examples/TailgatingDetector/TailgatingDetector.hs view
@@ -43,6 +43,8 @@ import Data.List (sortBy, (\\)) import FRP.Yampa+import FRP.Yampa.Conditional+import FRP.Yampa.EventS import FRP.Yampa.Utilities
+ examples/yampa-game/YampaSDL.hs view
@@ -0,0 +1,33 @@+module YampaSDL where++import Data.IORef+import FRP.Yampa as Yampa+import Graphics.UI.SDL as SDL++type TimeRef = IORef Int++yampaSDLTimeInit :: IO TimeRef+yampaSDLTimeInit = do+ timeRef <- newIORef (0 :: Int)+ _ <- yampaSDLTimeSense timeRef+ _ <- yampaSDLTimeSense timeRef+ _ <- yampaSDLTimeSense timeRef+ _ <- yampaSDLTimeSense timeRef+ return timeRef++-- | Updates the time in an IO Ref and returns the time difference+updateTime :: IORef Int -> Int -> IO Int+updateTime timeRef newTime = do+ previousTime <- readIORef timeRef+ writeIORef timeRef newTime+ return (newTime - previousTime)++yampaSDLTimeSense :: IORef Int -> IO Yampa.DTime+yampaSDLTimeSense timeRef = do+ -- Get time passed since SDL init+ newTime <- fmap fromIntegral SDL.getTicks++ -- Obtain time difference+ dt <- updateTime timeRef newTime+ let dtSecs = fromIntegral dt / 100+ return dtSecs
src/FRP/Yampa.hs view
@@ -53,11 +53,11 @@ -- -- * "FRP.Yampa.Task" ----- Minimal Complete FRP Definition+-- Minimal Complete FRP Definition: -- -- * "FRP.Yampa.Core" ----- Different FRP aspects+-- Different FRP aspects: -- -- * "FRP.Yampa.Basic" --@@ -85,9 +85,9 @@ -- -- * "FRP.Yampa.Simulation" -- Reactimation/evaluation ----- Internals+-- Internals: ----- * "FRP.Yampa.InternalCore"+-- * "FRP.Yampa.InternalCore" -- Module not exposed. -- -- Geometry: --@@ -274,7 +274,8 @@ edgeTag, -- :: a -> SF Bool (Event a) edgeJust, -- :: SF (Maybe a) (Event a) edgeBy, -- :: (a -> a -> Maybe b) -> a -> SF a (Event b)-+ maybeToEvent, -- :: Maybe a -> Event a+ -- ** Stateful event suppression notYet, -- :: SF (Event a) (Event a) once, -- :: SF (Event a) (Event a)
src/FRP/Yampa/Delays.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE GADTs, Rank2Types, CPP #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Delays@@ -28,7 +27,7 @@ import Control.Arrow import FRP.Yampa.Diagnostics-import FRP.Yampa.InternalCore (SF(..), SF'(..), sfTF', Transition, Time)+import FRP.Yampa.InternalCore (SF(..), SF'(..), Time) import FRP.Yampa.Basic import FRP.Yampa.Scan
src/FRP/Yampa/Event.hs view
@@ -10,6 +10,21 @@ -- -- Definition of Yampa Event type. --+-- Yampa Events represent discrete time-signals, meaning those that do not+-- change continuously. Examples of event-carrying signals would be mouse+-- clicks (in between clicks it is assumed that there is no click), some+-- keyboard events, button presses on wiimotes or window-manager events.+--+-- The type @Event@ is isomorphic to @Maybe@ (@Event a = NoEvent | Event a@)+-- but, semantically, a @Maybe@-carrying signal could change continuously,+-- whereas an @Event@-carrying signal should not. No mechanism in Yampa will+-- check this or misbehave if this assumption is violated.+--+-- Events are essential for many other Yampa constructs, like switches (see+-- @FRP.Yampa.Switches.switch@ for details).+--+----------------------------------------------------------------------------+-- -- Note on naming conventions used in this module. -- -- Names here might have to be rethought. It's really a bit messy.@@ -20,7 +35,7 @@ -- -- However, part of the names come from a desire to stay close to similar -- functions for the Maybe type. e.g. 'event', 'fromEvent', 'isEvent'.--- In many cases, this use of 'Event' can could understood to refer to the+-- In many cases, this use of 'Event' could be understood to refer to the -- constructor 'Event', not to the type name 'Event'. Thus this use of -- event should not be seen as a suffixing-with-type-name convention. But -- that is obviously not easy to see, and, more over, interpreting 'Event'@@ -284,7 +299,7 @@ -- | Event merge parameterized by a conflict resolution function. -- -- Applicative-based definition:--- mergeBy f re le = (f <$> re <*> le) <|> re <|> le+-- mergeBy f le re = (f <$> le <*> re) <|> le <|> re mergeBy :: (a -> a -> a) -> Event a -> Event a -> Event a mergeBy _ NoEvent NoEvent = NoEvent mergeBy _ le@(Event _) NoEvent = le@@ -295,6 +310,9 @@ -- merging the results. The first three arguments are mapping functions, -- the third of which will only be used when both events are present. -- Therefore, 'mergeBy' = 'mapMerge' 'id' 'id'+--+-- Applicative-based definition:+-- mapMerge lf rf lrf le re = (f <$> le <*> re) <|> (lf <$> le) <|> (rf <$> re) mapMerge :: (a -> c) -> (b -> c) -> (a -> b -> c) -> Event a -> Event b -> Event c mapMerge _ _ _ NoEvent NoEvent = NoEvent@@ -303,10 +321,18 @@ mapMerge _ _ lrf (Event l) (Event r) = Event (lrf l r) -- | Merge a list of events; foremost event has priority.+--+-- Foldable-based definition:+-- mergeEvents :: Foldable t => t (Event a) -> Event a+-- mergeEvents = asum mergeEvents :: [Event a] -> Event a mergeEvents = foldr lMerge NoEvent -- | Collect simultaneous event occurrences; no event if none.+--+-- Traverable-based definition:+-- catEvents :: Foldable t => t (Event a) -> Event (t a)+-- carEvents e = if (null e) then NoEvent else (sequenceA e) catEvents :: [Event a] -> Event [a] catEvents eas = case [ a | Event a <- eas ] of [] -> NoEvent@@ -314,6 +340,9 @@ -- | Join (conjunction) of two events. Only produces an event -- if both events exist.+--+-- Applicative-based definition:+-- joinE = liftA2 (,) joinE :: Event a -> Event b -> Event (a,b) joinE NoEvent _ = NoEvent joinE _ NoEvent = NoEvent
src/FRP/Yampa/Hybrid.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE GADTs, Rank2Types, CPP #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Hybrid
src/FRP/Yampa/Integration.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE GADTs, Rank2Types, CPP #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Integration
src/FRP/Yampa/InternalCore.hs view
@@ -190,7 +190,6 @@ #endif import FRP.Yampa.Diagnostics-import FRP.Yampa.Miscellany (dup) import FRP.Yampa.Event ------------------------------------------------------------------------------@@ -462,7 +461,7 @@ fdFanOut :: FunDesc a b -> FunDesc a c -> FunDesc a (b,c)-fdFanOut FDI FDI = FDG dup+fdFanOut FDI FDI = FDG (\a -> (a, a)) fdFanOut FDI (FDC c) = FDG (\a -> (a, c)) fdFanOut FDI fd2 = FDG (\a -> (a, (fdFun fd2) a)) fdFanOut (FDC b) FDI = FDG (\a -> (b, a))
src/FRP/Yampa/MergeableRecord.hs view
@@ -65,7 +65,7 @@ -- Type constructor for mergeable records.-newtype MergeableRecord a => MR a = MR (a -> a)+newtype MR a = MR (a -> a) -- Construction of a mergeable record.
src/FRP/Yampa/Point2.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses, FlexibleInstances, StandaloneDeriving #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Point2@@ -11,8 +11,6 @@ -- -- 2D point abstraction (R^2). ----- ToDo: Deriving Show, or provide dedicated show instance?--- ----------------------------------------------------------------------------------------- module FRP.Yampa.Point2 (@@ -33,7 +31,11 @@ -- 2D point, constructors and selectors. ------------------------------------------------------------------------------ -data RealFloat a => Point2 a = Point2 !a !a deriving (Eq, Show)+data Point2 a = RealFloat a => Point2 !a !a++deriving instance Eq a => Eq (Point2 a)++deriving instance Show a => Show (Point2 a) point2X :: RealFloat a => Point2 a -> a point2X (Point2 x _) = x
src/FRP/Yampa/Point3.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses, FlexibleInstances, StandaloneDeriving #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Point3@@ -32,7 +32,11 @@ -- 3D point, constructors and selectors. ------------------------------------------------------------------------------ -data RealFloat a => Point3 a = Point3 !a !a !a deriving Eq+data Point3 a = RealFloat a => Point3 !a !a !a++deriving instance Eq a => Eq (Point3 a)++deriving instance Show a => Show (Point3 a) point3X :: RealFloat a => Point3 a -> a point3X (Point3 x _ _) = x
src/FRP/Yampa/Time.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE GADTs, Rank2Types, CPP #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Time
src/FRP/Yampa/Vector2.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses, FlexibleInstances, StandaloneDeriving #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Vector2@@ -11,7 +11,6 @@ -- -- 2D vector abstraction (R^2). ----- ToDo: Deriving Show, or provide dedicated show instance? ----------------------------------------------------------------------------------------- module FRP.Yampa.Vector2 (@@ -40,7 +39,11 @@ -- result really would be a 2d vector), the only thing causing trouble is the -- use of atan2 in vector2Theta. Maybe atan2 can be generalized? -data RealFloat a => Vector2 a = Vector2 !a !a deriving (Eq,Show)+data Vector2 a = RealFloat a => Vector2 !a !a++deriving instance Eq a => Eq (Vector2 a)++deriving instance Show a => Show (Vector2 a) vector2 :: RealFloat a => a -> a -> Vector2 a vector2 = Vector2
src/FRP/Yampa/Vector3.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}+{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses, FlexibleInstances, StandaloneDeriving #-} ----------------------------------------------------------------------------------------- -- | -- Module : FRP.Yampa.Vector3@@ -11,7 +11,6 @@ -- -- 3D vector abstraction (R^3). ----- ToDo: Deriving Show, or provide dedicated show instance? ----------------------------------------------------------------------------------------- module FRP.Yampa.Vector3 (@@ -41,7 +40,11 @@ -- result really would be a 3d vector), the only thing causing trouble is the -- use of atan2 in vector3Theta and vector3Phi. Maybe atan2 can be generalized? -data RealFloat a => Vector3 a = Vector3 !a !a !a deriving (Eq, Show)+data Vector3 a = RealFloat a => Vector3 !a !a !a++deriving instance Eq a => Eq (Vector3 a)++deriving instance Show a => Show (Vector3 a) vector3 :: RealFloat a => a -> a -> a -> Vector3 a vector3 = Vector3
tests/AFRPTestsSscan.hs view
@@ -228,11 +228,6 @@ NoEvent] -maybeToEvent :: Maybe a -> Event a-maybeToEvent Nothing = NoEvent-maybeToEvent (Just a) = Event a-- edgeBy_sscan :: (a -> a -> Maybe b) -> a -> SF a (Event b) edgeBy_sscan f a = sscanPrim g a NoEvent where