rseInput :: String -> IO (ModuleState, String)
parseInput input = do
  let out = tail $ head (input =~ pattern :: [[String]])
      charging = head out == "Charging"
      percent = read (out !! 1) :: Int
      time = " (" ++ out !! 2 ++ ")"
      result = (if charging then "+" else "-") ++ show percent ++ "%" ++ (if not charging then time else "")
      state = case percent of
        n | n < 10 -> Critical
          | n < 20 -> Warning
        _ -> Good

  return (state, result)

  where pattern = "Battery [0-9]: (.+), (.+)%, (.+) (remaining)?"

parseInput :: String -> IO (ModuleState, String)
parseInput input = do
  let out = tail $ head (input =~ pattern :: [[String]])
      charging = head out == "Charging"
      percent = read (out !! 1) :: Int
      time = " (" ++ out !! 2 ++ ")"
      result = (if charging then "+" else "-") ++ show percent ++ "%" ++ (if not charging then time else "")
      state = case percent of
        n | n < 10 -> Critical
          | n < 20 -> Warning
        _ -> Good

  return (state, result)

  where pattern = "Battery [0-9]: (.+), (.+)%, (.+) (remaining)?"
parseInput input = do
  let out = tail $ head (input =~ pattern :: [[String]])
      charging = head out == "Charging"
      percent = read (out !! 1) :: Int
      time = " (" ++ out !! 2 ++ ")"
      result = (if charging then "+" else "-") ++ show percent ++ "%" ++ (if not charging then time else "")
      state = case percent of
        n | n < 10 -> Critical
          | n < 20 -> Warning
        _ -> Good

  return (state, result)

  where pattern = "Battery [0-9]: (.+), (.+)%, (.+) (remaining)?"