diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-05-15 15:30:53 +0200 | 
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-05-15 15:30:53 +0200 | 
| commit | 7885042246ac4a08e0f7b3ba27a7691a4908f3b6 (patch) | |
| tree | 3874d3a93048f899ae8d1ae8f2e9287fe2c6896c /src | |
| parent | 5d38dd48cc8e5349803064eb521117b3f20b3c74 (diff) | |
| download | trivmix-7885042246ac4a08e0f7b3ba27a7691a4908f3b6.tar trivmix-7885042246ac4a08e0f7b3ba27a7691a4908f3b6.tar.gz trivmix-7885042246ac4a08e0f7b3ba27a7691a4908f3b6.tar.bz2 trivmix-7885042246ac4a08e0f7b3ba27a7691a4908f3b6.tar.xz trivmix-7885042246ac4a08e0f7b3ba27a7691a4908f3b6.zip  | |
Fix read/show
Diffstat (limited to 'src')
| -rw-r--r-- | src/Trivmix/Types.hs | 6 | 
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Trivmix/Types.hs b/src/Trivmix/Types.hs index f01e023..abfdc43 100644 --- a/src/Trivmix/Types.hs +++ b/src/Trivmix/Types.hs  | |||
| @@ -62,7 +62,7 @@ dBToLin :: Float -> Level' | |||
| 62 | dBToLin x = either error id . refine $ 10 ** (0.05 * x) | 62 | dBToLin x = either error id . refine $ 10 ** (0.05 * x) | 
| 63 | 63 | ||
| 64 | instance Show Level where | 64 | instance Show Level where | 
| 65 | show (Lin x) = show x | 65 | show (Lin (unrefine -> x)) = show x | 
| 66 | show (DB (linToDb -> x)) = (show $ (withPrec x :: Milli)) ++ "dB" | 66 | show (DB (linToDb -> x)) = (show $ (withPrec x :: Milli)) ++ "dB" | 
| 67 | 67 | ||
| 68 | instance Read Level where | 68 | instance Read Level where | 
| @@ -75,7 +75,9 @@ instance Read Level where | |||
| 75 | unit' <- forM [1..lU] $ const get | 75 | unit' <- forM [1..lU] $ const get | 
| 76 | guard $ ((==) `on` CI.mk) unit unit' | 76 | guard $ ((==) `on` CI.mk) unit unit' | 
| 77 | return . DB $ dBToLin db | 77 | return . DB $ dBToLin db | 
| 78 | parseLin = Lin <$> readS_to_Prec readsPrec | 78 | parseLin = do | 
| 79 | lin <- readS_to_Prec readsPrec | ||
| 80 | either (const mzero) (return . Lin) $ refine lin | ||
| 79 | 81 | ||
| 80 | instance Eq Level where | 82 | instance Eq Level where | 
| 81 | (==) = (==) `on` toLin | 83 | (==) = (==) `on` toLin | 
