refactor: reorder data structures for better readability
This commit is contained in:
parent
df8bd3290f
commit
0b87d62ba0
1 changed files with 9 additions and 8 deletions
17
Proj2.hs
17
Proj2.hs
|
|
@ -56,25 +56,26 @@ import Debug.Trace
|
||||||
|
|
||||||
type GameState = [[Pitch]]
|
type GameState = [[Pitch]]
|
||||||
|
|
||||||
data Note = A | B | C | D | E | F | G
|
|
||||||
deriving (Eq, Show, Ord, Enum, Bounded)
|
|
||||||
|
|
||||||
data Octave = One | Two | Three
|
|
||||||
deriving (Eq, Ord, Enum, Bounded)
|
|
||||||
|
|
||||||
data Pitch = Pitch
|
data Pitch = Pitch
|
||||||
{ note :: Note,
|
{ note :: Note,
|
||||||
octave :: Octave
|
octave :: Octave
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
|
instance Show Pitch where
|
||||||
|
show (Pitch note octave) = show note ++ show octave
|
||||||
|
|
||||||
|
data Note = A | B | C | D | E | F | G
|
||||||
|
deriving (Bounded, Enum, Eq, Ord, Show)
|
||||||
|
|
||||||
|
data Octave = One | Two | Three
|
||||||
|
deriving (Bounded, Enum, Eq, Ord)
|
||||||
|
|
||||||
instance Show Octave where
|
instance Show Octave where
|
||||||
show One = "1"
|
show One = "1"
|
||||||
show Two = "2"
|
show Two = "2"
|
||||||
show Three = "3"
|
show Three = "3"
|
||||||
|
|
||||||
instance Show Pitch where
|
|
||||||
show (Pitch note octave) = show note ++ show octave
|
|
||||||
-- ==== REQUIRED FUNCTIONS ====================================================
|
-- ==== REQUIRED FUNCTIONS ====================================================
|
||||||
|
|
||||||
toPitch :: String -> Maybe Pitch
|
toPitch :: String -> Maybe Pitch
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue