Skip to content

Commit

Permalink
Update to 0.1.8, fix warnings, apply style
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Mar 14, 2020
1 parent 6d1283c commit 903df37
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 72 deletions.
55 changes: 55 additions & 0 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Taken from serokell metatemplates

steps:
- simple_align:
cases: false
top_level_patterns: false
records: false
- imports:
align: none
list_align: after_alias
pad_module_names: false
long_list_align: new_line
empty_list_align: inherit
list_padding: 2
separate_lists: false
space_surround: false
- language_pragmas:
style: compact
remove_redundant: true
- trailing_whitespace: {}
columns: 100
newline: native
language_extensions:
- BangPatterns
- ConstraintKinds
- DataKinds
- DefaultSignatures
- DeriveDataTypeable
- DeriveGeneric
- DerivingStrategies
- EmptyCase
- ExistentialQuantification
- ExplicitNamespaces
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GADTs
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- MultiWayIf
- NamedFieldPuns
- NoImplicitPrelude
- OverloadedLabels
- OverloadedStrings
- PatternSynonyms
- RecordWildCards
- RecursiveDo
- ScopedTypeVariables
- StandaloneDeriving
- TemplateHaskell
- TupleSections
- TypeApplications
- TypeFamilies
- ViewPatterns
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.8
==========
* Switched to ghc 8.8

0.1.7
==========
* Switch "script" output interpreter from "sh" to "/bin/env sh".
Expand Down
4 changes: 2 additions & 2 deletions orgstat.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: orgstat
version: 0.1.7
version: 0.1.8
synopsis: Statistics visualizer for org-mode
license: GPL-3
license-file: LICENSE
Expand Down Expand Up @@ -33,7 +33,7 @@ library
build-depends: aeson >= 0.11.2.0
, attoparsec
, ansi-terminal
, base >=4.11 && <4.12
, base >=4.13 && <4.14
, boxes >= 0.1.4
, bytestring
, colour >= 2.3.3
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with import <nixpkgs> { };
haskell.lib.buildStackProject {
ghc = haskell.packages.ghc844.ghc;
ghc = haskell.packages.ghc882.ghc;
name = "orgstat";
# firefox for xdg-open
buildInputs = [ zlib git openssh gnupg gnupg1compat xdg_utils firefox gmp ];
Expand Down
5 changes: 2 additions & 3 deletions src/OrgStat/Ast.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RankNTypes, TemplateHaskell #-}

-- | Abstract syntax tree for org.

Expand All @@ -22,7 +21,7 @@ module OrgStat.Ast
) where

import Control.Lens (ASetter', makeLenses)
import Data.Time (LocalTime, NominalDiffTime, diffUTCTime, localTimeToUTC, localTimeToUTC, utc)
import Data.Time (LocalTime, NominalDiffTime, diffUTCTime, localTimeToUTC, utc)

import Universum

Expand Down
13 changes: 5 additions & 8 deletions src/OrgStat/Config.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RecordWildCards, TemplateHaskell, TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}

-- | Configuration file types, together with json instances.
Expand All @@ -16,17 +14,16 @@ module OrgStat.Config
, OrgStatConfig (..)
) where

import Data.Aeson (FromJSON (..), Value (Object, String), withObject, withText, (.!=), (.:), (.:?))
import Data.Aeson (FromJSON(..), Value(Object, String), withObject, withText, (.!=), (.:), (.:?))
import Data.Aeson.Types (typeMismatch)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Text as T
import Data.Time (LocalTime)
import Data.Time.Format (defaultTimeLocale, parseTimeM)
import Universum

import OrgStat.Outputs.Types (BlockParams (..), ScriptParams (..), SummaryParams (..),
TimelineParams (..))
import OrgStat.Scope (AstPath (..), ScopeModifier (..))
import OrgStat.Outputs.Types
(BlockParams(..), ScriptParams(..), SummaryParams(..), TimelineParams(..))
import OrgStat.Scope (AstPath(..), ScopeModifier(..))
import OrgStat.Util (parseColour)

-- | Exception type for everything bad that happens with config,
Expand Down
11 changes: 6 additions & 5 deletions src/OrgStat/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import Universum

import Control.Lens (at, views, (.=))
import qualified Data.List.NonEmpty as NE
import Data.Time (LocalTime (..), TimeOfDay (..), addDays, getZonedTime, toGregorian,
zonedTimeToLocalTime)
import Data.Time
(LocalTime(..), TimeOfDay(..), addDays, getZonedTime, toGregorian, zonedTimeToLocalTime)
import Data.Time.Calendar (addGregorianMonthsRollOver)
import Data.Time.Calendar.WeekDate (toWeekDate)

import OrgStat.Ast (Org (..), cutFromTo, mergeClocks, orgTitle)
import OrgStat.Config (ConfDate (..), ConfOutput (..), ConfRange (..), ConfReport (..),
ConfScope (..), ConfigException (..), OrgStatConfig (..))
import OrgStat.Ast (Org(..), cutFromTo, mergeClocks, orgTitle)
import OrgStat.Config
(ConfDate(..), ConfOutput(..), ConfRange(..), ConfReport(..), ConfScope(..), ConfigException(..),
OrgStatConfig(..))
import OrgStat.IO (readOrgFile)
import OrgStat.Scope (applyModifiers)
import OrgStat.WorkMonad (WorkM, wcConfig, wdReadFiles, wdResolvedReports, wdResolvedScopes)
Expand Down
4 changes: 2 additions & 2 deletions src/OrgStat/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import qualified Data.Text.IO as TIO
import Data.Yaml (decodeEither')
import System.Directory (doesFileExist)
import System.FilePath (takeBaseName, takeExtension)
import Turtle (ExitCode (..), procStrict)
import Turtle (ExitCode(..), procStrict)

import OrgStat.Ast (Org)
import OrgStat.Config (ConfigException (ConfigParseException), OrgStatConfig)
import OrgStat.Config (ConfigException(ConfigParseException), OrgStatConfig)
import OrgStat.Logging
import OrgStat.Parser (runParser)
import OrgStat.Util (dropEnd)
Expand Down
7 changes: 4 additions & 3 deletions src/OrgStat/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import Universum

import Control.Concurrent.MVar (modifyMVar_, withMVar)
import qualified Data.Text as T
import Data.Time.Clock (UTCTime (..), getCurrentTime)
import Data.Time.Clock (UTCTime(..), getCurrentTime)
import Fmt (fmt, padRightF, (+|), (|+), (|++|))
import Fmt.Time (dateDashF, hmsF, subsecondF, tzNameF)
import System.Console.ANSI (Color (Blue, Green, Magenta, Red, Yellow), ColorIntensity (Vivid),
ConsoleLayer (Foreground), SGR (Reset, SetColor), setSGRCode)
import System.Console.ANSI
(Color(Blue, Green, Magenta, Red, Yellow), ColorIntensity(Vivid), ConsoleLayer(Foreground),
SGR(Reset, SetColor), setSGRCode)
import System.IO.Unsafe (unsafePerformIO)


Expand Down
8 changes: 4 additions & 4 deletions src/OrgStat/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import System.Directory (createDirectoryIfMissing)
import System.FilePath ((</>))
import Turtle (shell)

import OrgStat.CLI (CommonArgs (..))
import OrgStat.Config (ConfOutput (..), ConfOutputType (..), OrgStatConfig (..))
import OrgStat.CLI (CommonArgs(..))
import OrgStat.Config (ConfOutput(..), ConfOutputType(..), OrgStatConfig(..))
import OrgStat.Helpers (resolveOutput, resolveReport)
import OrgStat.Logging (logDebug, logInfo)
import OrgStat.Outputs (genBlockOutput, genSummaryOutput, processScriptOutput, processTimeline,
writeReport)
import OrgStat.Outputs
(genBlockOutput, genSummaryOutput, processScriptOutput, processTimeline, writeReport)
import OrgStat.WorkMonad (WorkM, wcCommonArgs, wcConfig)

-- | Main application logic.
Expand Down
2 changes: 1 addition & 1 deletion src/OrgStat/Outputs/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import qualified Data.Text as T
import Text.PrettyPrint.Boxes (center1, hsep, left, render, right, text, vcat)

import OrgStat.Ast (Org, filterHasClock, orgSubtrees, orgTitle, orgTotalDuration)
import OrgStat.Outputs.Types (BlockOutput (..), BlockParams (..))
import OrgStat.Outputs.Types (BlockOutput(..), BlockParams(..))
import OrgStat.Util (dropEnd, timeF)

data BlockFrames = BlockFrames
Expand Down
2 changes: 1 addition & 1 deletion src/OrgStat/Outputs/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import qualified Diagrams.Backend.SVG as DB
import qualified Diagrams.Prelude as D
import System.FilePath (replaceExtension)

import OrgStat.Outputs.Types (BlockOutput (..), SummaryOutput (..), TimelineOutput (..))
import OrgStat.Outputs.Types (BlockOutput(..), SummaryOutput(..), TimelineOutput(..))

-- | Things that reporters output an what we can do with them.
class ReportOutput a where
Expand Down
2 changes: 1 addition & 1 deletion src/OrgStat/Outputs/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import OrgStat.Ast (filterHasClock, orgTotalDuration)
import OrgStat.Config (confReports, crName)
import OrgStat.Helpers (resolveReport)
import OrgStat.Logging
import OrgStat.Outputs.Types (ScriptParams (..))
import OrgStat.Outputs.Types (ScriptParams(..))
import OrgStat.Util (timeF)
import OrgStat.WorkMonad (WorkM, wcConfig)

Expand Down
2 changes: 1 addition & 1 deletion src/OrgStat/Outputs/Summary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as A
import OrgStat.Ast (filterHasClock, orgTotalDuration)
import OrgStat.Config (confReports, crName)
import OrgStat.Helpers (resolveReport)
import OrgStat.Outputs.Types (SummaryOutput (..), SummaryParams (..))
import OrgStat.Outputs.Types (SummaryOutput(..), SummaryParams(..))
import OrgStat.Util (timeF)
import OrgStat.WorkMonad (WorkM, wcConfig)

Expand Down
13 changes: 6 additions & 7 deletions src/OrgStat/Outputs/Timeline.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RankNTypes, ScopedTypeVariables, TemplateHaskell #-}

-- | Timeline reporting output. Prouces a svg with columns.

Expand All @@ -11,16 +9,17 @@ module OrgStat.Outputs.Timeline
import Data.Colour.CIE (luminance)
import Data.List (lookup, nub)
import qualified Data.Text as T
import Data.Time (Day, DiffTime, LocalTime (..), defaultTimeLocale, formatTime, timeOfDayToTime)
import Data.Time (Day, DiffTime, LocalTime(..), defaultTimeLocale, formatTime, timeOfDayToTime)
import Diagrams.Backend.SVG (B)
import qualified Diagrams.Prelude as D
import qualified Prelude
import Text.Printf (printf)
import Universum

import OrgStat.Ast (Clock (..), Org (..), orgClocks, traverseTree)
import OrgStat.Outputs.Types (TimelineOutput (..), TimelineParams, tpBackground, tpColorSalt,
tpColumnHeight, tpColumnWidth, tpLegend, tpTopDay)
import OrgStat.Ast (Clock(..), Org(..), orgClocks, traverseTree)
import OrgStat.Outputs.Types
(TimelineOutput(..), TimelineParams, tpBackground, tpColorSalt, tpColumnHeight, tpColumnWidth,
tpLegend, tpTopDay)
import OrgStat.Util (addLocalTime, hashColour)


Expand Down
13 changes: 6 additions & 7 deletions src/OrgStat/Outputs/Types.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RankNTypes, TemplateHaskell #-}
-- | Types common among reports.

module OrgStat.Outputs.Types
Expand All @@ -23,13 +22,13 @@ module OrgStat.Outputs.Types
, BlockOutput (..)
) where

import Universum
import Universum

import Control.Lens (makeLenses)
import Control.Lens (makeLenses)

import Data.Default (Default (..))
import Diagrams.Backend.SVG (B)
import qualified Diagrams.Prelude as D
import Data.Default (Default(..))
import Diagrams.Backend.SVG (B)
import qualified Diagrams.Prelude as D

----------------------------------------------------------------------------
-- Timeline
Expand Down
8 changes: 3 additions & 5 deletions src/OrgStat/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@ module OrgStat.Parser

import Universum

import Control.Exception (Exception)
import qualified Data.Attoparsec.Text as A
import Data.Char (isSpace)
import qualified Data.OrgMode.Parse as O
import qualified Data.OrgMode.Types as O
import qualified Data.Text as T
import Data.Time (LocalTime (..), TimeOfDay (..), fromGregorian, getZonedTime, zonedTimeToLocalTime)
import Data.Time (LocalTime(..), TimeOfDay(..), fromGregorian, getZonedTime, zonedTimeToLocalTime)
import Data.Time.Calendar ()

import OrgStat.Ast (Clock (..), Org (..), orgTags, traverseTree)
import OrgStat.Ast (Clock(..), Org(..), orgTags, traverseTree)

----------------------------------------------------------------------------
-- Exceptions
----------------------------------------------------------------------------

data ParsingException =
ParsingException Text
data ParsingException = ParsingException Text
deriving (Show, Typeable)

instance Exception ParsingException
Expand Down
5 changes: 1 addition & 4 deletions src/OrgStat/Scope.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric, RankNTypes, ScopedTypeVariables, TemplateHaskell #-}

-- | This module defines how report input is formed.

Expand Down
5 changes: 2 additions & 3 deletions src/OrgStat/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import Data.Aeson.Types (Options, fieldLabelModifier)
import Data.Char (isLower, toLower)
import Data.Colour (Colour)
import Data.Colour.CIE (luminance)
import Data.Colour.SRGB (RGB (..), sRGB24, toSRGBBounded)
import Data.Hashable (hashWithSalt)
import Data.Colour.SRGB (RGB(..), sRGB24, toSRGBBounded)
import Data.List (nub)
import Data.List ((!!))
import Data.Time (LocalTime (..), NominalDiffTime, addUTCTime, localTimeToUTC, utc, utcToLocalTime)
import Data.Time (LocalTime(..), NominalDiffTime, addUTCTime, localTimeToUTC, utc, utcToLocalTime)
import Universum

-- | JSON/Yaml TH modifier. Each field of type "aoeuKek" turns into
Expand Down
2 changes: 1 addition & 1 deletion src/OrgStat/WorkMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module OrgStat.WorkMonad
import Universum

import Control.Lens (makeLenses)
import Data.Default (Default (def))
import Data.Default (Default(def))

import OrgStat.Ast (Org)
import OrgStat.CLI (CommonArgs)
Expand Down
11 changes: 5 additions & 6 deletions src/cli/Main.hs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ApplicativeDo, ScopedTypeVariables #-}

module Main where

import Universum

import Data.Version (showVersion)
import Options.Applicative.Simple (Parser, help, long, metavar, simpleOptions, strOption, switch,
value)
import Options.Applicative.Simple
(Parser, help, long, metavar, simpleOptions, strOption, switch, value)
import Paths_orgstat (version)
import System.Directory (getHomeDirectory)
import System.FilePath ((</>))

import OrgStat.CLI (CommonArgs, parseCommonArgs)
import OrgStat.IO (readConfig)
import OrgStat.Logging (Severity (..), initLogging, logDebug, logError)
import OrgStat.Logging (Severity(..), initLogging, logDebug, logError)
import OrgStat.Logic (runOrgStat)
import OrgStat.WorkMonad (WorkConfig (..), runWorkM)
import OrgStat.WorkMonad (WorkConfig(..), runWorkM)

data Args = Args
{ configPath :: !FilePath
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-12.18
resolver: lts-15.2

nix:
shell-file: shell.nix
Expand Down
Loading

0 comments on commit 903df37

Please sign in to comment.