active 0.2.0.1 → 0.2.0.2
raw patch · 3 files changed
+30/−12 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.Active: fromDuration :: Duration n -> n
+ Data.Active: fromTime :: Time n -> n
+ Data.Active: toDuration :: n -> Duration n
+ Data.Active: toTime :: n -> Time n
Files
- CHANGES +6/−0
- active.cabal +1/−1
- src/Data/Active.hs +23/−11
CHANGES view
@@ -1,3 +1,9 @@+0.2.0.2 (30 April 2015)+-----------------------++- reinstate `toTime`, `fromTime`, `toDuration`, `fromDuration`+ which got accidentally removed in 0.2+ 0.2.0.1 (22 April 2015) -----------------------
active.cabal view
@@ -1,5 +1,5 @@ name: active-version: 0.2.0.1+version: 0.2.0.2 synopsis: Abstractions for animation description: "Active" abstraction for animated things with finite start and end times. license: BSD3
src/Data/Active.hs view
@@ -8,8 +8,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ViewPatterns #-} -- UndecidableInstances needed for ghc < 707 {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -87,8 +87,8 @@ -- ** Time and duration - Time- , Duration+ Time, toTime, fromTime+ , Duration, toDuration, fromDuration -- ** Eras @@ -150,10 +150,10 @@ import Control.Lens hiding (backwards, (<.>)) import Data.Functor.Apply-import Data.Semigroup hiding (First (..))+import Data.Maybe import Data.Monoid (First (..))+import Data.Semigroup hiding (First (..)) import qualified Data.Vector as V-import Data.Maybe import Linear import Linear.Affine@@ -165,14 +165,20 @@ -- | An abstract type for representing /points in time/. Note that -- literal numeric values may be used as @Time@s, thanks to the the--- 'Num' and 'Fractional' instances. 'toTime' and 'fromTime' are--- also provided for convenience in converting between @Time@ and--- other numeric types.+-- 'Num' and 'Fractional' instances. newtype Time n = Time { unTime :: n } deriving (Eq, Ord, Show, Read, Enum, Num, Fractional, Real, RealFrac, Functor) makeWrapped ''Time +-- | A convenient wrapper function to convert a numeric value into a time.+toTime :: n -> Time n+toTime = Time++-- | A convenient unwrapper function to turn a time into a numeric value.+fromTime :: Time n -> n+fromTime = unTime+ instance Affine Time where type Diff Time = Duration (Time t1) .-. (Time t2) = Duration (t1 - t2)@@ -185,13 +191,19 @@ -- | An abstract type representing /elapsed time/ between two points -- in time. Note that durations can be negative. Literal numeric -- values may be used as @Duration@s thanks to the 'Num' and--- 'Fractional' instances. 'toDuration' and 'fromDuration' are also--- provided for convenience in converting between @Duration@s and--- other numeric types.+-- 'Fractional' instances. newtype Duration n = Duration n deriving (Eq, Ord, Show, Read, Enum, Num, Fractional, Real, RealFrac, Functor) makeWrapped ''Duration++-- | A convenient wrapper function to convert a numeric value into a duration.+toDuration :: n -> Duration n+toDuration = Duration++-- | A convenient unwrapper function to turn a duration into a numeric value.+fromDuration :: Duration n -> n+fromDuration = op Duration instance Applicative Duration where pure = Duration