music-dynamics-literal 1.7.1 → 1.7.2
raw patch · 2 files changed
+25/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Music.Dynamics.Literal: instance HasResolution a => IsDynamics (Fixed a)
+ Music.Dynamics.Literal: instance Integral a => IsDynamics (Ratio a)
+ Music.Dynamics.Literal: instance IsDynamics Float
Files
music-dynamics-literal.cabal view
@@ -1,6 +1,6 @@ name: music-dynamics-literal-version: 1.7.1+version: 1.7.2 author: Hans Hoglund maintainer: Hans Hoglund license: BSD3
src/Music/Dynamics/Literal.hs view
@@ -9,29 +9,36 @@ -- Stability : experimental -- Portability : portable ----- Provides overloaded pitch literals.+-- Provides overloaded dynamic literals. -- ------------------------------------------------------------------------------------- module Music.Dynamics.Literal (+ -- * IsDynamics class DynamicsL(..), IsDynamics(..), - pppppp, ppppp, pppp, ppp, pp, _p, - mp, mf, + -- * Literal values++ -- ** Standard dynamics+ pppppp, ppppp, pppp, ppp, pp, _p,+ mp, mf, _f, ff, fff, ffff, fffff, ffffff, + -- ** Other dynamics sffz, sfz, fz, rfz, fp ) where -import Data.Semigroup-import Control.Applicative+import Control.Applicative+import Data.Fixed+import Data.Ratio+import Data.Semigroup --- | +-- | -- Dynamics literal. -- -- First value is start value, second is end value.--- +-- -- * @(Just x, Nothing)@ is a constant dynamic of @x@ -- * @(Just x, Just y)@ is a dynamic varying from @x@ to @y@ -- * @(Nothing, Just y)@ is a dynamic varying from the previous level to @y@@@ -44,7 +51,7 @@ deriving (Eq, Show, Ord) -- Like Num can be expressed using arabic numerals, instances--- of IsDynamics can be expressed using Western pitch names (c, c sharp, c flat etc) +-- of IsDynamics can be expressed using Western pitch names (c, c sharp, c flat etc) class IsDynamics a where fromDynamics :: DynamicsL -> a @@ -59,6 +66,15 @@ instance IsDynamics a => IsDynamics [a] where fromDynamics = pure . fromDynamics++instance IsDynamics Float where+ fromDynamics x = realToFrac (fromDynamics x :: Double)++instance HasResolution a => IsDynamics (Fixed a) where+ fromDynamics x = realToFrac (fromDynamics x :: Double)++instance Integral a => IsDynamics (Ratio a) where+ fromDynamics x = realToFrac (fromDynamics x :: Double) instance IsDynamics Double where fromDynamics (DynamicsL (Just x, _)) = x