summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-05-15 15:30:53 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-05-15 15:30:53 +0200
commit7885042246ac4a08e0f7b3ba27a7691a4908f3b6 (patch)
tree3874d3a93048f899ae8d1ae8f2e9287fe2c6896c /src
parent5d38dd48cc8e5349803064eb521117b3f20b3c74 (diff)
downloadtrivmix-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.hs6
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'
62dBToLin x = either error id . refine $ 10 ** (0.05 * x) 62dBToLin x = either error id . refine $ 10 ** (0.05 * x)
63 63
64instance Show Level where 64instance 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
68instance Read Level where 68instance 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
80instance Eq Level where 82instance Eq Level where
81 (==) = (==) `on` toLin 83 (==) = (==) `on` toLin