Skip to content

Commit c612941

Browse files
Minor reformat.
1 parent 7646bbc commit c612941

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

Decoder.hs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import Data.ByteString.UTF8 qualified as UTF8
2020
data Cmd = Load ByteString | Jump Int | Pause | Quit
2121

2222
cmdToBS :: Cmd -> ByteString
23-
cmdToBS = \case
24-
Load f -> mconcat ["L ", f]
25-
-- Absolute or relative (+/-; not used here).
26-
Jump i -> mconcat ["J ", P.pack . show $ i]
27-
Pause -> "P" -- (un)pauses
28-
Quit -> "Q"
23+
cmdToBS (Load f) = "L " <> f
24+
cmdToBS (Jump i) = "J " <> P.pack (show i) -- can be relative with +/-; not used here
25+
cmdToBS Pause = "P" -- (un)pauses
26+
cmdToBS Quit = "Q"
2927

3028
------------------------------------------------------------------------
3129
-- Receive messages from mpg123
@@ -38,14 +36,13 @@ data Msg = I !Id3
3836

3937
-- ID3 info
4038
data Id3 = Id3
41-
{ id3title :: !ByteString
42-
, id3artist :: !ByteString
43-
, id3album :: !ByteString
44-
, id3str :: !ByteString
45-
-- , year :: Maybe ByteString
46-
-- , genre :: Maybe ByteString }
47-
}
48-
deriving stock (Eq, Show)
39+
{ id3title :: !ByteString
40+
, id3artist :: !ByteString
41+
, id3album :: !ByteString
42+
, id3str :: !ByteString
43+
-- , year :: Maybe ByteString
44+
-- , genre :: Maybe ByteString }
45+
} deriving stock (Eq, Show)
4946

5047
-- Frame decoding status updates (once per frame).
5148
-- Current-frame and frames-remaining are integers; current-time and
@@ -55,8 +52,7 @@ data Frame = Frame {
5552
framesLeft :: !Int,
5653
currentTime :: !(Fixed E2),
5754
timeLeft :: !(Fixed E2)
58-
}
59-
deriving stock (Eq, Show)
55+
} deriving stock (Eq, Show)
6056

6157
-- Stop/pause status.
6258
data Status = Stopped | Paused | Playing
@@ -76,8 +72,7 @@ doP s = do
7672
'0' -> pure $ P Stopped
7773
'1' -> pure $ P Paused
7874
'2' -> pure $ P Playing
79-
-- recent mpg123 outputs 3 for end of song; don't need
80-
_ -> Nothing
75+
_ -> Nothing -- don't need P 3 at end of song
8176

8277
-- Frame decoding status updates (once per frame).
8378
doF :: ByteString -> Maybe Msg

0 commit comments

Comments
 (0)