packages feed

orgstat 0.0.2 → 0.0.3

raw patch · 5 files changed

+15/−13 lines, 5 files

Files

orgstat.cabal view
@@ -1,5 +1,5 @@ name:                orgstat-version:             0.0.2+version:             0.0.3 synopsis:            Statistics visualizer for org-mode license:             GPL-3 license-file:        LICENSE
src/OrgStat/Config.hs view
@@ -103,11 +103,13 @@     parseJSON (String s) | any (`T.isPrefixOf` s) ["day", "week", "month"] = do         let splitted = T.splitOn "-" $ if "-" `T.isInfixOf` s then s else s <> "-"             [range, number] = splitted-            constructor = case range of-                "day"   -> ConfBlockDay-                "week"  -> ConfBlockWeek-                "month" -> ConfBlockMonth-                _       -> panic "ConfRange@parseJSON"+            constructor :: (Monad m, MonadFail m) => Integer -> m ConfRange+            constructor i = case range of+                "day"   -> pure $ ConfBlockDay i+                "week"  -> pure $ ConfBlockWeek i+                "month" -> pure $ ConfBlockMonth i+                t       -> fail $ "ConfRange@parseJSON can't parse " <> T.unpack t <>+                                  " should be [day|week|month]"             numberParsed                 | number == "" = pure 0                 | otherwise = case readMaybe (T.unpack number) of@@ -116,7 +118,7 @@         when (length splitted /= 2) $             fail $ "Couldn't parse range " <> T.unpack s <>                    ", splitted is " <> show splitted-        constructor <$> numberParsed+        constructor =<< numberParsed     parseJSON (Object v)       = ConfFromTo <$> v .: "from" <*> v .: "to"     parseJSON invalid          = typeMismatch "ConfRange" invalid 
src/OrgStat/Logic.hs view
@@ -39,17 +39,17 @@ convertRange :: (MonadIO m) => ConfRange -> m (LocalTime, LocalTime) convertRange range = case range of     (ConfFromTo f t)  -> (,) <$> fromConfDate f <*> fromConfDate t-    (ConfBlockDay i) | i < 0 -> panic $ "ConfBlockDay i is <0: " <> show i+    (ConfBlockDay i) | i < 0 -> error $ "ConfBlockDay i is <0: " <> show i     (ConfBlockDay 0) -> (,) <$> (localFromDay <$> startOfDay) <*> curTime     (ConfBlockDay i) -> do         d <- (negate (i - 1) `addDays`) <$> startOfDay         pure $ localFromDayPair ((negate 1) `addDays` d, d)-    (ConfBlockWeek i) | i < 0 -> panic $ "ConfBlockWeek i is <0: " <> show i+    (ConfBlockWeek i) | i < 0 -> error $ "ConfBlockWeek i is <0: " <> show i     (ConfBlockWeek 0) -> (,) <$> (localFromDay <$> startOfWeek) <*> curTime     (ConfBlockWeek i) -> do         d <- (negate (i - 1) `addWeeks`) <$> startOfWeek         pure $ localFromDayPair ((negate 1) `addWeeks` d, d)-    (ConfBlockMonth i) | i < 0 -> panic $ "ConfBlockMonth i is <0: " <> show i+    (ConfBlockMonth i) | i < 0 -> error $ "ConfBlockMonth i is <0: " <> show i     (ConfBlockMonth 0) -> (,) <$> (localFromDay <$> startOfMonth) <*> curTime     (ConfBlockMonth i) -> do         d <- addGregorianMonthsRollOver (negate $ i-1) <$> startOfMonth@@ -91,7 +91,7 @@             scope <- getScope conf timelineScope crName             let scopeFiles = NE.toList $ csPaths scope                 neededOrgs =-                    map (\f -> fromMaybe (panic $ scopeNotFound (T.pack f) crName) $+                    map (\f -> fromMaybe (error $ scopeNotFound (T.pack f) crName) $                                M.lookup f allParsedOrgs)                         scopeFiles             let orgTop = Org "/" [] [] $ map (\(fn,o) -> o & orgTitle .~ fn) neededOrgs
src/OrgStat/Scope.hs view
@@ -94,7 +94,7 @@     unless (existsPath path org) $         throwError $ MEWrongParam m $ "Path " <> show path <> " doesn't exist"     pure $-        fromMaybe (panic "applyModifier@ModSelectSubtree is broken") $+        fromMaybe (error "applyModifier@ModSelectSubtree is broken") $         org ^. atPath path applyModifier _ org = pure org -- TODO 
src/OrgStat/Util.hs view
@@ -63,7 +63,7 @@ hashColour :: (Hashable a) => Int -> a -> Colour Double hashColour salt item = colours !! (hashWithSalt salt item `mod` length colours)   where-    broken = panic "Util#hashColour is broken"+    broken = error "Util#hashColour is broken"     range = [-5,0,5]     colours = filter (\c -> luminance c < 0.8 && luminance c > 0.06) mutate     ac :: Word8 -> Integer -> Word8