From 3989c89f0f3945f949d2929cc0af3994910a2771 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 2 Aug 2016 22:46:52 +0200 Subject: minor cleanup --- src/Trivstream/Options.hs | 3 ++- src/Trivstream/Options/Utils.hs | 1 + src/Trivstream/Types.hs | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Trivstream/Options.hs b/src/Trivstream/Options.hs index a777942..1762f60 100644 --- a/src/Trivstream/Options.hs +++ b/src/Trivstream/Options.hs @@ -8,6 +8,7 @@ module Trivstream.Options import Trivstream.Types import Trivstream.Options.Utils import Paths_trivstream (version) +import Development.GitRev import Options.Applicative @@ -16,7 +17,7 @@ import Control.Monad.Reader import Control.Monad.IO.Class -withOptions :: MonadIO m => ReaderT Configuration a -> IO a +withOptions :: MonadIO m => ReaderT Configuration m a -> m a withOptions f = liftIO (execParser options) >>= runReaderT f where options = options' `info` mconcat [ header $ concat [ "trivstream " diff --git a/src/Trivstream/Options/Utils.hs b/src/Trivstream/Options/Utils.hs index 30694d8..bab27b3 100644 --- a/src/Trivstream/Options/Utils.hs +++ b/src/Trivstream/Options/Utils.hs @@ -8,6 +8,7 @@ import Options.Applicative import Data.Char import Data.Maybe +import Text.Read (readMaybe) import Network.Socket diff --git a/src/Trivstream/Types.hs b/src/Trivstream/Types.hs index 8cdd592..6dbd949 100644 --- a/src/Trivstream/Types.hs +++ b/src/Trivstream/Types.hs @@ -7,6 +7,7 @@ module Trivstream.Types , SampleRate(..) , Configuration(..) , Mode (..) + , module Data.Default.Class ) where @@ -32,7 +33,7 @@ instance Serialize ChannelPosition data AudioBackend = Pulse | Jack - deriving (Enum, Eq, Generic) + deriving (Enum, Eq, Generic, Show, Read) instance Default AudioBackend where def = Pulse @@ -54,7 +55,7 @@ instance Serialize SampleRate data AudioConfig = AudioConfig { _aBackend :: AudioBackend , _aChannels :: [Maybe ChannelPosition] - , _aRate :: SampleRate + , _aRate :: Maybe SampleRate } deriving (Generic) makeLenses ''AudioConfig @@ -62,14 +63,14 @@ instance Default AudioConfig where def = AudioConfig { _aBackend = def , _aChannels = [Just $ ChannelNormal PanLeft, Just $ ChannelNormal PanRight] - , _aRate = def + , _aRate = Just def } instance Serialize AudioConfig data Mode = Server | Client - deriving (Enum, Eq, Generic, Show) + deriving (Enum, Eq, Generic, Show, Read) instance Default Mode where def = Server -- cgit v1.2.3