activitystreams-aeson 0.2.0.1 → 0.2.0.2
raw patch · 7 files changed
+47/−62 lines, 7 filesdep ~basesetup-changed
Dependency ranges changed: base
Files
- Codec/ActivityStream.hs +1/−3
- Codec/ActivityStream/Internal.hs +8/−10
- Codec/ActivityStream/LensInternal.hs +8/−21
- Codec/ActivityStream/Representation.hs +10/−13
- Codec/ActivityStream/Schema.hs +11/−11
- Setup.hs +1/−1
- activitystreams-aeson.cabal +8/−3
Codec/ActivityStream.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TemplateHaskell #-}- {-| Module : Codec.ActivityStream Description : The basic Activity Streams structures@@ -23,4 +21,4 @@ ( module Codec.ActivityStream.Representation ) where -import Codec.ActivityStream.Representation+import Codec.ActivityStream.Representation
Codec/ActivityStream/Internal.hs view
@@ -1,17 +1,15 @@-{-# LANGUAGE ViewPatterns #-}- module Codec.ActivityStream.Internal (commonOpts, commonOptsCC, ensure) where -import Control.Monad (mzero)-import Data.Aeson-import Data.Aeson.TH-import Data.Char-import Data.HashMap.Strict (HashMap, member)-import Data.Monoid ((<>))-import Data.Text (Text, pack, unpack)+import Control.Monad (mzero)+import Data.Aeson+import Data.Aeson.TH+import Data.Char+import Data.HashMap.Strict (HashMap, member)+import Data.Monoid ((<>))+import Data.Text (Text, pack, unpack) ensure :: Monad m => String -> HashMap Text Value -> [Text] -> m ()-ensure objName obj keys = mapM_ go keys+ensure objName obj = mapM_ go where go k | member k obj = return () | otherwise = fail ("Object \"" <> objName <>
Codec/ActivityStream/LensInternal.hs view
@@ -1,6 +1,5 @@-{-# LANGUAGE RankNTypes #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE RankNTypes #-} -- Okay, I'm gonna justify this in a comment: I will never, under any -- circumstances, build a library that has an explicit `lens` dependency.@@ -22,32 +21,20 @@ -- And that is why this module reimplement a few `lens` functions. module Codec.ActivityStream.LensInternal- ( get- , set- , Lens'+ ( Lens' , makeLens , makeAesonLensMb , makeAesonLens ) where -import Data.Aeson as Aeson+import Data.Aeson as Aeson import qualified Data.HashMap.Strict as HM-import Data.Maybe (fromJust)-import Data.Text (Text)---- We need these to write get and set-newtype C a b = C { fromC :: a } deriving (Functor)-newtype I a = I { fromI :: a } deriving (Functor)+import Data.Maybe (fromJust)+import Data.Text (Text) -- This is the same type alias as in @Control.Lens@, and so can be used -- anywhere lenses are needed.-type Lens' a b = forall f. Functor f => (b -> f b) -> (a -> f a)--get :: Lens' a b -> a -> b-get lens a = fromC (lens C a)--set :: Lens' a b -> b -> a -> a-set lens x a = fromI (lens (const I x) a)+type Lens' a b = forall f. Functor f => (b -> f b) -> a -> f a makeLens :: (a -> b) -> (b -> a -> a) -> Lens' a b makeLens get set f a = (`set` a) `fmap` f (get a)@@ -76,5 +63,5 @@ makeAesonLens :: (FromJSON v, ToJSON v) => Text -> Lens' c Aeson.Object -> Lens' c v makeAesonLens key fromObj = fromObj . makeLens g s- where g o = fromJust (HM.lookup key o >>= fromJSON')- s v o = HM.insert key (toJSON v) o+ where g o = fromJust (HM.lookup key o >>= fromJSON')+ s v = HM.insert key (toJSON v)
Codec/ActivityStream/Representation.hs view
@@ -78,18 +78,15 @@ , cRest ) where -import Data.Aeson ( FromJSON(..)- , ToJSON(..)- , Result(..)- , fromJSON- )-import qualified Data.Aeson as A-import Data.Time.Clock (UTCTime)-import qualified Data.HashMap.Strict as HM-import Data.Text (Text)+import Data.Aeson (FromJSON (..), Result (..),+ ToJSON (..), fromJSON)+import qualified Data.Aeson as A+import qualified Data.HashMap.Strict as HM+import Data.Text (Text)+import Data.Time.Clock (UTCTime) -import Codec.ActivityStream.Internal (ensure)-import Codec.ActivityStream.LensInternal+import Codec.ActivityStream.Internal (ensure)+import Codec.ActivityStream.LensInternal -- | Some types of objects may have an alternative visual representation in -- the form of an image, video or embedded HTML fragments. A 'MediaLink'@@ -388,7 +385,7 @@ makeActivity actor published = Activity $ HM.insert "actor" (toJSON actor) $ HM.insert "published" (toJSON published)- $ HM.empty+ HM.empty -- | JSON Activity Streams 1.0 specificies that an @Activity@ may be used as an -- @Object@. In such a case, the object may have fields permitted on either an@@ -446,4 +443,4 @@ $ HM.insert "totalItems" (toJSON (length objs)) $ HM.insert "items" (toJSON objs) $ HM.insert "url" (toJSON url)- $ HM.empty+ HM.empty
Codec/ActivityStream/Schema.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE Rank2Types #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Rank2Types #-}+{-# LANGUAGE TemplateHaskell #-} {-| Module : Codec.ActivityStream.Schema@@ -86,16 +86,16 @@ , moodImage ) where -import qualified Data.Aeson as Aeson-import Data.Aeson.TH (deriveJSON)-import Data.Time.Clock (UTCTime)-import Data.Aeson ( FromJSON(..), ToJSON(..) )-import qualified Data.HashMap.Strict as HM-import Data.Text (Text)+import Data.Aeson (FromJSON (..), ToJSON (..))+import qualified Data.Aeson as Aeson+import Data.Aeson.TH (deriveJSON)+import qualified Data.HashMap.Strict as HM+import Data.Text (Text)+import Data.Time.Clock (UTCTime) -import Codec.ActivityStream.Internal-import Codec.ActivityStream.LensInternal-import Codec.ActivityStream+import Codec.ActivityStream+import Codec.ActivityStream.Internal+import Codec.ActivityStream.LensInternal -- | The ActivityStreams Base Schema specification defines the -- following core verbs in addition to the default post verb that is
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple+import Distribution.Simple main = defaultMain
activitystreams-aeson.cabal view
@@ -1,5 +1,5 @@ name: activitystreams-aeson-version: 0.2.0.1+version: 0.2.0.2 synopsis: An interface to the ActivityStreams specification description: An interface to the <http://activitystrea.ms/ Activity Streams>@@ -18,18 +18,23 @@ license-file: LICENSE author: Getty Ritter maintainer: gettylefou@gmail.com-copyright: (c) 2014 Getty Ritter+copyright: (c) 2016 Getty Ritter+homepage: https://github.com/aisamanra/activitystreams-aeson category: Codec build-type: Simple cabal-version: >=1.10 +source-repository head+ type: git+ location: git://github.com/aisamanra/activitystreams-aeson.git+ library exposed-modules: Codec.ActivityStream Codec.ActivityStream.Schema other-modules: Codec.ActivityStream.Internal, Codec.ActivityStream.Representation, Codec.ActivityStream.LensInternal- build-depends: base >=4.7 && <4.8,+ build-depends: base >=4.7 && <4.9, aeson ==0.8.*, text >=1.1, time >=1.4,