{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module Language.Chords
  ( Chord (..)
  , ChordType (..)
  , getChordNotes
  ) where

import Language.Notes  (Note)
import Language.Shifts ((#))

data ChordType =
  Major
  | Minor
  | Diminished
  | MajorSeventh
  | MinorSeventh
  | DominantSeventh
  | Suspended
  | Augmented
  | Extended
  deriving (Int -> ChordType -> ShowS
[ChordType] -> ShowS
ChordType -> String
(Int -> ChordType -> ShowS)
-> (ChordType -> String)
-> ([ChordType] -> ShowS)
-> Show ChordType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChordType] -> ShowS
$cshowList :: [ChordType] -> ShowS
show :: ChordType -> String
$cshow :: ChordType -> String
showsPrec :: Int -> ChordType -> ShowS
$cshowsPrec :: Int -> ChordType -> ShowS
Show, Int -> ChordType
ChordType -> Int
ChordType -> [ChordType]
ChordType -> ChordType
ChordType -> ChordType -> [ChordType]
ChordType -> ChordType -> ChordType -> [ChordType]
(ChordType -> ChordType)
-> (ChordType -> ChordType)
-> (Int -> ChordType)
-> (ChordType -> Int)
-> (ChordType -> [ChordType])
-> (ChordType -> ChordType -> [ChordType])
-> (ChordType -> ChordType -> [ChordType])
-> (ChordType -> ChordType -> ChordType -> [ChordType])
-> Enum ChordType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ChordType -> ChordType -> ChordType -> [ChordType]
$cenumFromThenTo :: ChordType -> ChordType -> ChordType -> [ChordType]
enumFromTo :: ChordType -> ChordType -> [ChordType]
$cenumFromTo :: ChordType -> ChordType -> [ChordType]
enumFromThen :: ChordType -> ChordType -> [ChordType]
$cenumFromThen :: ChordType -> ChordType -> [ChordType]
enumFrom :: ChordType -> [ChordType]
$cenumFrom :: ChordType -> [ChordType]
fromEnum :: ChordType -> Int
$cfromEnum :: ChordType -> Int
toEnum :: Int -> ChordType
$ctoEnum :: Int -> ChordType
pred :: ChordType -> ChordType
$cpred :: ChordType -> ChordType
succ :: ChordType -> ChordType
$csucc :: ChordType -> ChordType
Enum)

type BaseNote = Note

data Chord = Chord
  { Chord -> ChordType
getType     :: ChordType
  , Chord -> BaseNote
getBaseNote :: BaseNote
  }
  deriving (Int -> Chord -> ShowS
[Chord] -> ShowS
Chord -> String
(Int -> Chord -> ShowS)
-> (Chord -> String) -> ([Chord] -> ShowS) -> Show Chord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Chord] -> ShowS
$cshowList :: [Chord] -> ShowS
show :: Chord -> String
$cshow :: Chord -> String
showsPrec :: Int -> Chord -> ShowS
$cshowsPrec :: Int -> Chord -> ShowS
Show)

getChordNotes :: Chord -> [Note]
getChordNotes :: Chord -> [BaseNote]
getChordNotes (Chord ChordType
Major BaseNote
baseNote) = [BaseNote
baseNote, BaseNote
baseNote BaseNote -> Int -> BaseNote
forall a. ShiftTone a => a -> Int -> a
# Int
2, BaseNote
baseNote BaseNote -> Int -> BaseNote
forall a. ShiftTone a => a -> Int -> a
# Int
4]