Some refining of data types
Getty Ritter
8 years ago
26 | 26 |
build-depends: base >=4.7 && <4.9
|
27 | 27 |
, brick
|
28 | 28 |
, lens-family-core
|
| 29 |
, lens-family-th
|
29 | 30 |
, text
|
30 | 31 |
, containers
|
31 | 32 |
, vty
|
| 1 |
{-# LANGUAGE TemplateHaskell #-}
|
| 2 |
|
1 | 3 |
module Hypsibius.Data where
|
2 | 4 |
|
3 | 5 |
import Data.Sequence (Seq)
|
4 | 6 |
import qualified Data.Sequence as S
|
5 | 7 |
import Data.Text (Text)
|
6 | |
|
7 | |
data Instrument = Instrument
|
8 | |
{ _instrSource :: Oscillator
|
9 | |
} deriving (Eq, Show)
|
10 | |
|
11 | |
newtype InstrRef = InstrRef { fromInstrRef :: Int }
|
12 | |
deriving (Eq, Show)
|
| 8 |
import Data.Word (Word8)
|
| 9 |
import Lens.Family2.TH
|
13 | 10 |
|
14 | 11 |
data Oscillator
|
15 | 12 |
= OscSine
|
16 | 13 |
| OscSquare
|
17 | 14 |
deriving (Eq, Show)
|
18 | 15 |
|
| 16 |
data Instrument = Instrument
|
| 17 |
{ _instrSource :: Oscillator
|
| 18 |
} deriving (Eq, Show)
|
| 19 |
|
| 20 |
$(makeLenses ''Instrument)
|
| 21 |
|
| 22 |
newtype InstrRef = InstrRef { _fromInstrRef :: Int }
|
| 23 |
deriving (Eq, Show)
|
| 24 |
|
| 25 |
$(makeLenses ''InstrRef)
|
| 26 |
|
19 | 27 |
data Note = Note
|
20 | 28 |
{ _noteCents :: Double
|
21 | 29 |
, _noteAppearance :: Text
|
22 | 30 |
} deriving (Eq, Show)
|
23 | 31 |
|
24 | |
newtype NoteRef = NoteRef { fromNoteRef :: Int }
|
| 32 |
$(makeLenses ''Note)
|
| 33 |
|
| 34 |
newtype NoteRef = NoteRef { _fromNoteRef :: Int }
|
25 | 35 |
deriving (Eq, Show)
|
| 36 |
|
| 37 |
$(makeLenses ''NoteRef)
|
26 | 38 |
|
27 | 39 |
data Scale = Scale
|
28 | 40 |
{ _scaleName :: Text
|
29 | 41 |
, _scaleTotalCents :: Double
|
30 | 42 |
, _scaleNotes :: Seq Note
|
31 | 43 |
} deriving (Eq, Show)
|
| 44 |
|
| 45 |
$(makeLenses ''Scale)
|
32 | 46 |
|
33 | 47 |
data Event = Event
|
34 | 48 |
deriving (Eq, Show)
|
|
37 | 51 |
{
|
38 | 52 |
} deriving (Eq, Show)
|
39 | 53 |
|
| 54 |
data Beats
|
| 55 |
= BeatsSimple Word8
|
| 56 |
| BeatsAdditive [Word8]
|
| 57 |
| BeatsFractional Word8 Word8
|
| 58 |
deriving (Eq, Show)
|
| 59 |
|
| 60 |
$(makeTraversals ''Beats)
|
| 61 |
|
| 62 |
data Signature = Signature
|
| 63 |
{ _sigPerBar :: Beats
|
| 64 |
, _sigBeatUnit :: Word8
|
| 65 |
} deriving (Eq, Show)
|
| 66 |
|
| 67 |
$(makeLenses ''Signature)
|
| 68 |
|
40 | 69 |
data Song = Song
|
41 | 70 |
{ _songScale :: Scale
|
42 | 71 |
, _songTracks :: Seq Track
|
43 | 72 |
} deriving (Eq, Show)
|
| 73 |
|
| 74 |
$(makeLenses ''Song)
|