From 5c0a79bbbd654615c9ff0743906022d0d02b1538 Mon Sep 17 00:00:00 2001 From: Michael Knabe Date: Sat, 12 Dec 2015 12:37:27 +0100 Subject: Move wind speed calculation functions to let clause --- src/Plugins/Monitors/Weather.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Plugins/Monitors/Weather.hs b/src/Plugins/Monitors/Weather.hs index b2520a9..a25005f 100644 --- a/src/Plugins/Monitors/Weather.hs +++ b/src/Plugins/Monitors/Weather.hs @@ -100,6 +100,10 @@ noWind = WindInfo "μ" "μ" "0" "0" "0" "0" pWind :: Parser WindInfo pWind = let tospace = manyTill anyChar (char ' ') + toKmh knots = knots $* 1.852 + toMs knots = knots $* 0.514 + ($*) :: String -> Double -> String + op1 $* op2 = show (round ((read op1::Double) * op2)::Integer) -- Occasionally there is no wind and a METAR report gives simply, "Wind: Calm:0" wind0 = do manyTill skipRestOfLine (string "Wind: Calm:0") @@ -121,11 +125,6 @@ pWind = manyTill anyChar newline return $ WindInfo cardinal azimuth mph knot (toKmh knot) (toMs knot) in try wind0 <|> try windVar <|> try wind <|> return noWind - where - toKmh knots = knots $* 1.852 - toMs knots = knots $* 0.514 - ($*) :: String -> Double -> String - op1 $* op2 = show (round ((read op1::Double) * op2)::Integer) pTemp :: Parser (Int, Int) pTemp = do let num = digit <|> char '-' <|> char '.' -- cgit v1.2.3