Revision dd4c56ed src/Utils.hs

b/src/Utils.hs
4 4

  
5 5
import Data.List
6 6
import Data.Either
7
import System
8
import System.IO
9
import Monad
7 10

  
8 11
import Debug.Trace
9 12

  
......
65 68
-- | Coefficient of variation.
66 69
varianceCoeff :: Floating a => [a] -> a
67 70
varianceCoeff lst = (stdDev lst) / (fromIntegral $ length lst)
71

  
72
-- | Get a Right result or print the error and exit
73
readData :: (String -> IO (Either String String)) -> String -> IO String
74
readData fn host = do
75
  nd <- fn host
76
  when (isLeft nd) $
77
       do
78
         putStrLn $ fromLeft nd
79
         exitWith $ ExitFailure 1
80
  return $ fromRight nd

Also available in: Unified diff