packages feed

taskwarrior 0.4.1.0 → 0.5.0.0

raw patch · 7 files changed

+39/−45 lines, 7 filesdep +unordered-containersdep ~aesondep ~containers

Dependencies added: unordered-containers

Dependency ranges changed: aeson, containers

Files

CHANGELOG.md view
@@ -1,17 +1,14 @@ # Revision history for taskwarrior -## 0.4.1.0+## 0.5.0.0 -* Make JSON parsing compatible with taskwarrior 2.6.+* Drop Wait constructor from Status. This is a breaking change and is only compatible with taskwarrior > 2.6.0 -## 0.4.0.0+The 0.5 release is meant to be used with aeson < 2.0, the 0.6 release works with aeson >= 2.0 -### Breaking Change-* Change UDA Type from HashMap to ordered Map.+## 0.3.1.0 -### Maintenance-* Update to aeson 2.0.-* Improve test.nix+* Add support with the JSON Format of taskwarrior 2.6.  ## 0.3.0.0 
README.md view
@@ -35,10 +35,10 @@  Also I'd be curious to know what you use this library for. -This project uses fourmolu as code formatter.+This project uses brittany in default configuration as code formatter.+The tests on github will check for hlints, missing docs and unapplied formatting.  ## Help & Contact -You can always open an issue on GitHub. Contacting @maralorn:maralorn.de on-matrix is also an option. But of course that won’t be public and therefore not-help anyone else.+You can always open an issue on GitHub. You can also ask in `#haskell-taskwarrior` on freenode irc. If you don‘t have an irc client you can log in via [the webchat](https://webchat.freenode.net/#haskell-taskwarrior).+Shooting @maralorn a mail is also an option. But of course that won’t be public and therefore not help anyone else.
src/Taskwarrior/Status.hs view
@@ -33,7 +33,6 @@   = Pending   | Deleted {end :: UTCTime}   | Completed {end :: UTCTime}-  | Waiting {wait :: UTCTime}   | Recurring       { recur :: Text       , mask :: Mask@@ -47,7 +46,6 @@     "pending" -> pure Pending     "deleted" -> Deleted <$> (o .: "end" >>= Time.parse)     "completed" -> Completed <$> (o .: "end" >>= Time.parse)-    "waiting" -> Waiting <$> (o .: "wait" >>= Time.parse)     "recurring" -> Recurring <$> o .: "recur" <*> o .: "mask"     str -> typeMismatch "status" (Aeson.String str) @@ -57,7 +55,6 @@   Pending -> [statusLabel "pending"]   Deleted{..} -> [statusLabel "deleted", "end" .= Time.toValue end]   Completed{..} -> [statusLabel "completed", "end" .= Time.toValue end]-  Waiting{..} -> [statusLabel "waiting", "wait" .= Time.toValue wait]   Recurring{..} -> [statusLabel "recurring", "recur" .= recur, "mask" .= mask]  where   statusLabel :: Text -> Pair
src/Taskwarrior/Task.hs view
@@ -20,27 +20,22 @@  import Prelude hiding (id) -import Control.Applicative ((<|>)) import Control.Monad (join) import Data.Aeson (   FromJSON,   ToJSON,   Value,   parseJSON,-  withArray,   withObject,   withText,   (.:),   (.:?),-  (.=),+  (.=), withArray  ) import qualified Data.Aeson as Aeson-import qualified Data.Aeson.Key as Key-import qualified Data.Aeson.KeyMap as KeyMap import qualified Data.Aeson.Types as Aeson.Types-import Data.Foldable (toList) import qualified Data.Foldable as Foldable-import qualified Data.Map.Strict as Map+import qualified Data.HashMap.Strict as HashMap import Data.Maybe (fromMaybe) import qualified Data.Maybe as Maybe import qualified Data.Semigroup as Semigroup@@ -61,12 +56,14 @@ import qualified Taskwarrior.Status as Status import qualified Taskwarrior.Time as Time import Taskwarrior.UDA (UDA)+import Data.Foldable (toList)+import Control.Applicative ((<|>))  {- | A 'Task' represents a task from taskwarrior.  The specification demands, that the existence of some fields is dependent on the status of the task.  Those fields are therefore bundled in 'Status' as a sum-type. - All fields in an imported task which are not part of the specification will be put in the 'UDA' (user defined attributes) 'Data.Map.Strict.Map Data.Text.Text'.+ All fields in an imported task which are not part of the specification will be put in the 'UDA' (user defined attributes) 'Data.HashMap.Strict.HashMap'.   Since the json can have multiple semantically equivalent representations of a task first serializing and then deserializing is not identity.  But deserializing and then serializing should be. (Thus making serializing and deserializing idempotent.)@@ -80,6 +77,7 @@   , description :: Text   , start :: Maybe UTCTime   , modified :: Maybe UTCTime+  , wait :: Maybe UTCTime   , due :: Maybe UTCTime   , until :: Maybe UTCTime   , annotations :: Set Annotation@@ -125,7 +123,7 @@ instance FromJSON Task where   parseJSON = withObject "Task" $ \object -> do     let parseTimeFromFieldMay = parseFromFieldWithMay Time.parse object-        uda = Map.filterWithKey (\k _ -> k `notElem` reservedKeys) . Map.mapKeys Key.toText $ KeyMap.toMap object+        uda = HashMap.filterWithKey (\k _ -> k `notElem` reservedKeys) object     status <- Status.parseFromObject object     recurringChild <- RecurringChild.parseFromObjectMay object     uuid <- object .: "uuid"@@ -134,6 +132,7 @@     entry <- object .: "entry" >>= Time.parse     description <- object .: "description"     start <- parseTimeFromFieldMay "start"+    wait <- parseTimeFromFieldMay "wait"     modified <- parseTimeFromFieldMay "modified"     due <- parseTimeFromFieldMay "due"     until_ <- parseTimeFromFieldMay "until"@@ -147,7 +146,7 @@       maybe         (pure mempty)         parseUuidList-        (KeyMap.lookup (Key.fromText "depends") object)+        (HashMap.lookup "depends" object)     tags <- Foldable.fold <$> object .:? "tags"     urgency <- fromMaybe 0 <$> object .:? "urgency"     pure Task{until = until_, ..}@@ -158,17 +157,15 @@   Text ->   Aeson.Types.Parser (Maybe a) parseFromFieldWithMay parser object name =-  traverse parser (KeyMap.lookup (Key.fromText name) object)+  traverse parser (HashMap.lookup name object)  parseUuidList :: Aeson.Value -> Aeson.Types.Parser (Set UUID) parseUuidList val =-  (withArray "Array of uuid strings" $ fmap Set.fromList . mapM parseJSON . toList) val-    <|> ( withText "Comma separated list of uuids" $-            fmap Set.fromList-              . mapM (parseJSON . Aeson.String)-              . Text.splitOn ","-        )-      val+  (withArray "Array of uuid strings" $ fmap Set.fromList . mapM parseJSON . toList) val <|>+  (withText "Comma separated list of uuids" $+    fmap Set.fromList+      . mapM (parseJSON . Aeson.String)+      . Text.splitOn ",") val  instance ToJSON Task where   toJSON Task{until = until_, ..} =@@ -185,6 +182,7 @@           (\(name, value) -> (name .=) . Time.toValue <$> value)           [ ("start", start)           , ("modified", modified)+          , ("wait", wait)           , ("due", due)           , ("scheduled", scheduled)           , ("until", until_)@@ -202,7 +200,7 @@               . Set.toList           )         <> ifNotNullSet tags ("tags" .=)-        <> Map.toList (Map.mapKeys Key.fromText uda)+        <> HashMap.toList uda  ifNotNullSet :: (Ord b) => Set b -> (Set b -> a) -> [a] ifNotNullSet set f =@@ -210,7 +208,7 @@   )     [f set] --- | Makes a fresh Task with the given mandatory fields uuid, entry time and description. See createTask for a non-pure version which needs less parameters.+-- | Makes a Task with the given mandatory fields uuid, entry time and description. See createTask for a non-pure version which needs less parameters. makeTask :: UUID -> UTCTime -> Text -> Task makeTask uuid entry description =   Task@@ -227,9 +225,10 @@     , start = Nothing     , scheduled = Nothing     , until = Nothing+    , wait = Nothing     , annotations = mempty     , depends = mempty     , tags = mempty     , urgency = 0-    , uda = Map.empty+    , uda = HashMap.empty     }
src/Taskwarrior/UDA.hs view
@@ -1,11 +1,11 @@--- | User defined attributes are stored in a 'Map' from 'Text' to json 'Value's because we have no type information about them.+-- | User defined attributes are stored in a 'HashMap' from 'Text' to json 'Value's because we have no type information about them. module Taskwarrior.UDA (   UDA, ) where  import Data.Aeson (Value)-import Data.Map.Strict (Map)+import Data.HashMap.Strict (HashMap) import Data.Text (Text)  -- | A field will in practice only be a number or a string.-type UDA = Map Text Value+type UDA = HashMap Text Value
taskwarrior.cabal view
@@ -4,7 +4,7 @@ -- PVP summary:     +-+------- breaking API changes --                  | | +----- non-breaking API additions --                  | | | +--- code changes with no API change-version: 0.4.1.0+version: 0.5.0.0 synopsis:           Types and aeson instances for taskwarrior tasks description:   Types and aeson instances for the https://taskwarrior.org task import/export feature@@ -45,7 +45,7 @@     StrictData    build-depends:-    , aeson                 >=2.0.0.0  && < 2.1+    , aeson                 >=1.4.2.0  && < 1.6     , base                  >=4.11     && < 4.16     , bytestring            >=0.10.8.2 && < 0.12     , containers            >=0.5.0.0  && < 0.7@@ -53,6 +53,7 @@     , random                >=1.1      && < 1.3     , text                  ^>=1.2.3.0     , time                  >=1.8.0.2  && < 1.13+    , unordered-containers  ^>=0.2.9.0     , uuid                  ^>=1.3.13    hs-source-dirs:     src@@ -68,13 +69,13 @@   build-depends:     , aeson     , base-    , containers     , hspec                 >=2.7.1 && < 2.9     , QuickCheck            >=2.13.2 && <2.15     , quickcheck-instances  ^>=0.3.22     , taskwarrior     , text     , time+    , unordered-containers     , uuid    default-language:   Haskell2010
test/TaskSpec.hs view
@@ -8,7 +8,7 @@ import Prelude hiding (id)  import Data.Aeson-import qualified Data.Map.Strict as Map+import qualified Data.HashMap.Strict as HashMap import Data.Time import Taskwarrior.Annotation import Taskwarrior.Mask@@ -48,7 +48,6 @@       [ pure Pending       , Deleted <$> arbitrary       , Completed <$> arbitrary-      , Waiting <$> arbitrary       , Recurring <$> arbitrary <*> arbitrary       ] @@ -81,6 +80,7 @@     entry <- arbitrary     description <- arbitrary     start <- arbitrary+    wait <- arbitrary     modified <- arbitrary     due <- arbitrary     until_ <- arbitrary@@ -91,5 +91,5 @@     depends <- arbitrary     tags <- arbitrary     urgency <- arbitrary-    uda <- Map.fromList . fmap (second String) <$> arbitrary+    uda <- HashMap.fromList . fmap (second String) <$> arbitrary     pure Task{until = until_, ..}