music-parts 1.6.2 → 1.7
raw patch · 2 files changed
+59/−15 lines, 2 filesdep +adjunctionsdep +lensPVP ok
version bump matches the API change (PVP)
Dependencies added: adjunctions, lens
API changes (from Hackage documentation)
+ Music.Parts: instance Enum a => Enum (Option a)
+ Music.Parts: instance Integral a => Integral (First a)
+ Music.Parts: instance Integral a => Integral (Option a)
+ Music.Parts: instance Monoid BasicPart
+ Music.Parts: instance Monoid Part
+ Music.Parts: instance Num a => Num (First a)
+ Music.Parts: instance Num a => Num (Option a)
+ Music.Parts: instance Real a => Real (First a)
+ Music.Parts: instance Real a => Real (Option a)
+ Music.Parts: instance Semigroup BasicPart
+ Music.Parts: instance Semigroup Part
Files
- music-parts.cabal +5/−3
- src/Music/Parts.hs +54/−12
music-parts.cabal view
@@ -1,6 +1,6 @@ name: music-parts-version: 1.6.2+version: 1.7 author: Hans Hoglund maintainer: Hans Hoglund license: BSD3@@ -21,12 +21,14 @@ location: git://github.com/music-suite/music-parts.git library - build-depends: base >= 4 && < 5,+ build-depends: base >= 4 && < 5,+ lens >= 4.1.2 && < 4.2,+ semigroups >= 0.13.0.1 && < 1, time, random,- semigroups >= 0.13.0.1 && < 1, semigroupoids, data-default,+ adjunctions, roman-numerals exposed-modules: Music.Parts -- Music.Parts.Strings
src/Music/Parts.hs view
@@ -112,6 +112,10 @@ import Data.Semigroup import Data.Typeable import Data.Maybe+import Data.Traversable (traverse)+import Control.Lens (toListOf)+import Data.Functor.Adjunction (unzipR)+import Control.Applicative import Text.Numeral.Roman (toRoman) import qualified Data.List @@ -238,8 +242,14 @@ toEnum x = Part Tutti (toEnum x) def fromEnum (Part solo instr subp) = fromEnum instr +-- Semantics: Monoid (Option . First)+instance Monoid Part where+ mappend x _ = x+ mempty = def+instance Semigroup Part where+ (<>) = mappend instance Default Part where- def = Part def def def+ def = Part def def def -- | -- @a \`containsPart\` b@ holds if the set of players represented by a is an improper subset of the @@ -400,14 +410,14 @@ (30, (0, 5.0, 0, "Distortion Guitar")), (31, (0, 5.0, 0, "Guitar Harmonics")), - (32, (0, 8.0, 0, "Acoustic Bass")),- (33, (0, 8.0, 0, "Electric Bass (finger)")),- (34, (0, 8.0, 0, "Electric Bass (pick)")),- (35, (0, 8.0, 0, "Fretless Bass")),- (36, (0, 8.0, 0, "Slap Bass 1")),- (37, (0, 8.0, 0, "Slap Bass 2")),- (38, (0, 8.0, 0, "Synth Bass 1")),- (39, (0, 8.0, 0, "Synth Bass 2")),+ (32, (0, 8.0, 2, "Acoustic Bass")),+ (33, (0, 8.0, 2, "Electric Bass (finger)")),+ (34, (0, 8.0, 2, "Electric Bass (pick)")),+ (35, (0, 8.0, 2, "Fretless Bass")),+ (36, (0, 8.0, 2, "Slap Bass 1")),+ (37, (0, 8.0, 2, "Slap Bass 2")),+ (38, (0, 8.0, 2, "Synth Bass 1")),+ (39, (0, 8.0, 2, "Synth Bass 2")), (40, (12, 7.1, 0, "Violin")), (41, (13, 7.2, 1, "Viola")),@@ -675,12 +685,44 @@ | Pno -}+-- TODO move+instance Num a => Num (Option a) where+ (+) = liftA2 (+)+ (-) = liftA2 (-)+ (*) = liftA2 (*)+ abs = fmap abs+ signum = fmap signum+ fromInteger = pure . fromInteger+instance Integral a => Integral (Option a) where+ quotRem x y = unzipR $ liftA2 quotRem x y+ toInteger = toInteger . get where get = (head.toListOf traverse)+instance Real a => Real (Option a) where+ toRational = toRational . get where get = (head.toListOf traverse)+instance Enum a => Enum (Option a) where+ fromEnum = fromEnum . get where get = (head.toListOf traverse)+ toEnum = pure . toEnum +instance Num a => Num (First a) where+ (+) = liftA2 (+)+ (-) = liftA2 (-)+ (*) = liftA2 (*)+ abs = fmap abs+ signum = fmap signum+ fromInteger = pure . fromInteger+instance Integral a => Integral (First a) where+ quotRem x y = unzipR $ liftA2 quotRem x y+ toInteger = toInteger . get where get = (head.toListOf traverse)+instance Real a => Real (First a) where+ toRational = toRational . get where get = (head.toListOf traverse)+-- instance Enum a => Enum (First a) where+ -- toEnum = toEnum . get where get = (head.toListOf traverse)+ -- fromEnum = pure . fromEnum -newtype BasicPart = BasicPart { getBasicPart :: Integer }- deriving (Eq, Ord, Num, Integral, Real, Enum, Typeable)+newtype BasicPart = BasicPart { getBasicPart :: Option (First Integer) }+ deriving (Eq, Ord, Num, Integral, Real, Enum, Typeable, Semigroup, Monoid) -instance Default BasicPart where def = BasicPart 0+instance Default BasicPart where+ def = mempty instance Show BasicPart where show _ = ""