varying 0.7.0.2 → 0.7.0.3
raw patch · 7 files changed
+46/−38 lines, 7 filesdep ~basedep ~transformers
Dependency ranges changed: base, transformers
Files
- bench/Main.hs +15/−15
- src/Control/Varying/Core.hs +6/−2
- src/Control/Varying/Event.hs +1/−1
- src/Control/Varying/Spline.hs +2/−2
- src/Control/Varying/Tween.hs +7/−10
- test/Main.hs +14/−7
- varying.cabal +1/−1
bench/Main.hs view
@@ -7,25 +7,25 @@ main :: IO () main = do let run v a = runIdentity (fst <$> runVarT v a)- defaultMain $ [ bgroup "runVarT" [ bench "1" $ nf (run $ chain 1) 0- , bench "2" $ nf (run $ chain 2) 0- , bench "4" $ nf (run $ chain 4) 0- , bench "8" $ nf (run $ chain 8) 0- , bench "16" $ nf (run $ chain 16) 0- , bench "32" $ nf (run $ chain 32) 0- , bench "64" $ nf (run $ chain 64) 0- , bench "128" $ nf (run $ chain 128) 0- ]- , bgroup "TweenT"- [ bench "tweenStream" $- nf (run $ tweenStream myTween 0) 0- ]- ]+ defaultMain [ bgroup "runVarT" [ bench "1" $ nf (run $ chain 1) 0+ , bench "2" $ nf (run $ chain 2) 0+ , bench "4" $ nf (run $ chain 4) 0+ , bench "8" $ nf (run $ chain 8) 0+ , bench "16" $ nf (run $ chain 16) 0+ , bench "32" $ nf (run $ chain 32) 0+ , bench "64" $ nf (run $ chain 64) 0+ , bench "128" $ nf (run $ chain 128) 0+ ]+ , bgroup "TweenT"+ [ bench "tweenStream" $+ nf (run $ tweenStream myTween 0) 0+ ]+ ] return () chain :: Int -> Var Int Int chain n = seq x x- where x = foldl (~>) (var (+1)) $ take (n - 1) $ cycle [var (+1)]+ where x = foldl (>>>) (var (+1)) $ replicate (n - 1) $ var (+1) myTween :: Tween Float Float () myTween = do
src/Control/Varying/Core.hs view
@@ -1,6 +1,10 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-}++#if __GLASGOW_HASKELL__ > 710 +{-# OPTIONS_GHC -Wno-redundant-constraints #-}+#endif -- | -- Module: Control.Varying.Core -- Copyright: (c) 2015 Schell Scivally@@ -50,10 +54,10 @@ import Control.Category import Control.Monad import Control.Monad.IO.Class-import Control.Applicative import Data.Functor.Identity import Debug.Trace-#if __GLASGOW_HASKELL__ <= 709+import Control.Applicative +#if __GLASGOW_HASKELL__ < 710 import Data.Monoid #endif --------------------------------------------------------------------------------
src/Control/Varying/Event.hs view
@@ -59,7 +59,7 @@ import Data.Foldable (foldl') -- stuff for FAMP-#if __GLASGOW_HASKELL__ <= 707+#if __GLASGOW_HASKELL__ < 709 import Control.Applicative import Data.Function #endif
src/Control/Varying/Spline.hs view
@@ -57,7 +57,7 @@ import Data.Monoid -- stuff for FAMP-#if __GLASGOW_HASKELL__ <= 707+#if __GLASGOW_HASKELL__ < 709 import Control.Applicative import Data.Function #endif@@ -141,7 +141,7 @@ -- "Hello" -- 2 instance MonadTrans (SplineT a b) where- lift f = SplineT $ const $ fmap Left f+ lift f = SplineT $ const $ f >>= return . Left -- | A spline can do IO if its underlying monad has a MonadIO instance. It -- takes the result of the IO action as its immediate return value.
src/Control/Varying/Tween.hs view
@@ -14,7 +14,6 @@ -- arbitrary types, and possibly tween one type into another (pipe -- dreams). --- {-# LANGUAGE Rank2Types #-} module Control.Varying.Tween ( -- * Tweening types@@ -55,10 +54,8 @@ import Control.Varying.Core import Control.Varying.Event import Control.Varying.Spline-import Control.Arrow-import Control.Applicative import Control.Monad.Trans.State-import Control.Monad.Trans.Class+import Control.Applicative import Data.Functor.Identity --------------------------------------------------------------------------------@@ -69,27 +66,27 @@ -- out http://www.gizma.com/easing/. -------------------------------------------------------------------------------- -- | Ease in quadratic.-easeInQuad :: (Num t, Fractional t, Real f) => Easing t f+easeInQuad :: (Fractional t, Real f) => Easing t f easeInQuad c t b = c * realToFrac (t*t) + b -- | Ease out quadratic.-easeOutQuad :: (Num t, Fractional t, Real f) => Easing t f+easeOutQuad :: (Fractional t, Real f) => Easing t f easeOutQuad c t b = (-c) * realToFrac (t * (t - 2)) + b -- | Ease in cubic.-easeInCubic :: (Num t, Fractional t, Real f) => Easing t f+easeInCubic :: (Fractional t, Real f) => Easing t f easeInCubic c t b = c * realToFrac (t*t*t) + b -- | Ease out cubic.-easeOutCubic :: (Num t, Fractional t, Real f) => Easing t f+easeOutCubic :: (Fractional t, Real f) => Easing t f easeOutCubic c t b = let t' = realToFrac t - 1 in c * (t'*t'*t' + 1) + b -- | Ease in by some power.-easeInPow :: (Num t, Fractional t, Real f) => Int -> Easing t f+easeInPow :: (Fractional t, Real f) => Int -> Easing t f easeInPow power c t b = c * (realToFrac t^power) + b -- | Ease out by some power.-easeOutPow :: (Num t, Fractional t, Real f) => Int -> Easing t f+easeOutPow :: (Fractional t, Real f) => Int -> Easing t f easeOutPow power c t b = let t' = realToFrac t - 1 c' = if power `mod` 2 == 1 then c else -c
test/Main.hs view
@@ -1,15 +1,22 @@+{-# LANGUAGE CPP #-}++#if __GLASGOW_HASKELL__ > 710 +{-# OPTIONS_GHC -Wno-redundant-constraints #-}+#endif+ module Main where + import Test.Hspec hiding (after, before)-import Control.Applicative import Control.Varying-import Control.Monad.Trans.Class import Control.Monad.IO.Class-import Control.Monad.Trans.State-import Control.Monad (when) import Data.Functor.Identity import Data.Time.Clock +#if __GLASGOW_HASKELL__ < 710+import Control.Applicative+#endif+ main :: IO () main = hspec $ do describe "before" $ @@ -128,7 +135,7 @@ let r :: Spline () String () r = do x <- capture $ do step "a" step "b"- return 2+ return (2 :: Int) case x of (Just "b", 2) -> step "True" _ -> step "False"@@ -183,8 +190,8 @@ let f = (+1) x = 1 it "(homomorphism) pure f <*> pure x = pure (f x)" $- (fst $ runIdentity $ scanVar (pure f <*> pure x) [0..5])- `shouldBe` (fst $ runIdentity $ scanVar (pure $ f x) [0..5])+ fst (runIdentity $ scanVar (pure f <*> pure x) [0..5])+ `shouldBe` fst (runIdentity $ scanVar (pure $ f x) [0..5]) describe "spline's applicative instance" $ do let ident = pure id <*> sinc
varying.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.7.0.2+version: 0.7.0.3 -- A short (one-line) description of the package. synopsis: FRP through value streams and monadic splines.