-
Notifications
You must be signed in to change notification settings - Fork 1
Housekeeping #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edwisdom
wants to merge
12
commits into
develop
Choose a base branch
from
housekeeping
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Housekeeping #25
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5f5d680
FIX: Made transposeChord a safe exportable function, and added show i…
edwisdom b143d6b
FIX: Made a smart constructor for IQualities to handle cases where Di…
edwisdom 5d97044
ADD: Added a bunch of new non-heptatonic modes, and changed baseModeT…
edwisdom 415a4a4
DOC: Removed TODO about potentially changing the scale extension type…
edwisdom 89d57f1
FIX: Made smart constructor for a mode actually smart
edwisdom 8b7aee0
Added a newline to the end of the file
ChrisEPhifer f52ad40
Simplified some code via algebraic laws
ChrisEPhifer d617f04
Deprecated `iQualFrom`, implemented true smart constructors for `IQua…
ChrisEPhifer b2017f9
Undo a silly unnecessary import
ChrisEPhifer 1480526
Haddocks for IQuality smart constructors
ChrisEPhifer 0bb8021
Added predicates to determine quality
ChrisEPhifer a291d6a
Added unidirectional pattern synonyms for IQuality, updated downstrea…
ChrisEPhifer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ import Common.Utils (modByFrom) | |
|
|
||
| import Control.Monad (zipWithM) | ||
|
|
||
| import Data.Maybe (fromJust) | ||
| import Data.Maybe (fromJust, isJust, fromMaybe) | ||
| import Data.Set as S hiding (filter) | ||
|
|
||
| -- | Intervals are defined by a quality and a size. | ||
|
|
@@ -74,8 +74,6 @@ normalizeIntervalSize = modByFrom 7 1 | |
| -- TODO: This should probably return an Either String Interval (or an error | ||
| -- type in place of String) instead of Maybe Interval, in order to facilitate | ||
| -- more sophisticated error handling / reporting. | ||
| -- | ||
| -- TODO: Make sure diminished and augmented don't get arguments > 11 | ||
| intervalFrom :: Quality -> Int -> Maybe Interval | ||
| intervalFrom q s = if normalizedSize `elem` goodSizes then | ||
| Just Interval { getQuality = q, getSize = normalizedSize } | ||
|
|
@@ -113,7 +111,7 @@ intervalToDistance interval = | |
| -- Minor shifts | ||
| Interval Minor i -> | ||
| case baseQuality i of | ||
| Major -> subtract 1 <$> intervalToDistance (Interval Major i) | ||
| Major -> subtract 1 <$> intervalToDistance (Interval major i) | ||
| Perfect -> Nothing | ||
|
|
||
| -- Augmented shifts | ||
|
|
@@ -149,35 +147,35 @@ instance Invertible Interval where | |
| newI = normalizeIntervalSize $ 9 - normalizeIntervalSize i | ||
| newQual = | ||
| case iQual of | ||
| Major -> Minor | ||
| Minor -> Major | ||
| Perfect -> Perfect | ||
| (Augmented x) -> Diminished x | ||
| (Diminished x) -> Augmented x | ||
| Major -> minor | ||
| Minor -> major | ||
| Perfect -> perfect | ||
| (Augmented x) -> fromJust $ diminished x | ||
| (Diminished x) -> fromJust $ augmented x | ||
|
Comment on lines
149
to
+154
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check it out! We can pattern match using the old constructor names, but we can't actually use those constructors to make new values of |
||
| in | ||
| Interval newQual newI | ||
|
|
||
| -- | When adding an integer to an interval with this infix operator, | ||
| -- the interval's distance is increased by that integer without | ||
| -- changing its size. | ||
| -- | ||
| -- TODO: Figure out what to do if dim and aug < 11 and this function | ||
| -- receives an integer argument > 11. | ||
| -- | ||
| -- prop> intervalToDistance i + x == intervalToDistance (i <+> x) | ||
| -- prop> getSize (i <+> _) == getSize i | ||
| infixl 6 <+> | ||
| (<+>) :: Interval -> Int -> Interval | ||
| Interval iQual i <+> x = | ||
| Interval (iterate modFunc iQual !! abs x) i | ||
| Interval iQual i <+> x = Interval newQual i | ||
| where | ||
| unwrapMaybeQ :: (Quality -> Maybe Quality) -> Quality -> Quality | ||
| unwrapMaybeQ f qual = fromMaybe (baseQuality i) (f qual) | ||
| modFunc = | ||
| case (baseQuality i, signum x) of | ||
| (Perfect, 1) -> raisePerfect | ||
| (Major, 1) -> raiseMajor | ||
| (Perfect, -1) -> lowerPerfect | ||
| (Major, -1) -> lowerMajor | ||
| (_, 0) -> id | ||
| (_, 0) -> return | ||
| smartMod = unwrapMaybeQ modFunc | ||
| newQual = iterate smartMod iQual !! abs x | ||
|
|
||
| -- | When subtracting an integer from an interval with this infix operator, | ||
| -- the interval's distance is decreased by that integer without | ||
|
|
@@ -252,7 +250,5 @@ nthDegreeIntervals ints n = S.map (|-| noteInterval) ints | |
| where | ||
| noteInterval = toAscList ints !! (n - 1) | ||
|
|
||
| zipToIntervalSet :: [Quality] -> [Int] -> Maybe (Set Interval) | ||
| zipToIntervalSet quals sizes = | ||
| do ints <- zipWithM intervalFrom quals sizes | ||
| return $ fromList ints | ||
| zipToIntervalSet :: [Quality] -> [Int] -> Set Interval | ||
| zipToIntervalSet quals sizes = fromList (fromJust . uncurry intervalFrom <$> zip quals sizes) | ||
ChrisEPhifer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this per the suggestion I made to your original commits.