on develop help sign in
Renaming and adding placeholder notes
commit76c10c04d4a388e4cdc647c1e2623f50658a2f8c authorBrendan Hay <brendan.g.hay@gmail.com> dateSun 20 Mar 2016, 17:51 (11 years ago) parent02608fb
3 files changed+24−10
gogol/src/Network/Google.hs+17−4 gogol/src/Network/Google/Auth/Scope.hs+5−4 gogol/src/Network/Google/Env.hs+2−2
gogol/src/Network/Google.hs+17−4
@@ -28,6 +28,9 @@
2828-- application stack.
2929module Network.Google
3030 (
31+ -- * Usage
32+ -- $usage
33+
3134 -- * Running Google Actions
3235 Google (..)
3336 , MonadGoogle (..)
@@ -44,12 +47,14 @@ module Network.Google
4447 , getApplicationDefault
4548
4649 -- ** Authorization
50+ -- $auth
51+
4752 , allow
4853 , forbid
4954 , (!)
5055
56+ , AllowScopes
5157 , type HasScope
52− , type HasScope'
5358
5459 -- * Sending Requests
5560 , send
@@ -152,17 +157,17 @@ runGoogle :: (MonadResource m, HasEnv s r) => r -> Google s a -> m a
152157runGoogle e m = liftResourceT $ runReaderT (unGoogle m) (e ^. environment)
153158
154159-- | Monads in which 'Google' actions may be embedded.
155−class ( Allow s
156− , Functor m
160+class ( Functor m
157161 , Applicative m
158162 , Monad m
159163 , MonadIO m
160164 , MonadCatch m
165+ , AllowScopes s
161166 ) => MonadGoogle s m | m -> s where
162167 -- | Lift a computation to the 'Google' monad.
163168 liftGoogle :: Google s a -> m a
164169
165−instance Allow s => MonadGoogle s (Google s) where
170+instance AllowScopes s => MonadGoogle s (Google s) where
166171 liftGoogle = id
167172
168173instance MonadBaseControl IO (Google s) where
@@ -243,6 +248,14 @@ upload x = send . MediaUpload x
243248hoistError :: MonadThrow m => Either Error a -> m a
244249hoistError = either (throwingM _Error) return
245250
251+{- $usage
252+Usage explanation and example placeholder.
253+-}
254+
255+{- $auth
256+Authorization explanation and example placeholder.
257+-}
258+
246259{- $async
247260Requests can be sent asynchronously, but due to guarantees about resource closure
248261require the use of <http://hackage.haskell.org/package/lifted-async lifted-async>.
gogol/src/Network/Google/Auth/Scope.hs+5−4
@@ -65,6 +65,7 @@ type family HasScope (s :: [Symbol]) a :: Constraint where
6565 HasScope s a = (s `HasScope'` Scopes a) ~ 'True
6666
6767-- | Check if any of actual supplied scopes 's' exist in the required set 'a'.
68+-- If the required set 'a' is empty, then succeed.
6869type family HasScope' s a where
6970 HasScope' s '[] = 'True -- No scopes are required.
7071 HasScope' (x ': xs) a = x ∈ a || HasScope' xs a
@@ -80,19 +81,19 @@ type family (++) xs ys where
8081 (++) '[] b = b
8182 (++) (a ': as) bs = a ': (as ++ bs)
8283
83−class Allow a where
84+class AllowScopes a where
8485 -- | Obtain a list of supported 'OAuthScope' values from a proxy.
8586 allowScopes :: proxy a -> [OAuthScope]
8687
87−instance Allow '[] where
88+instance AllowScopes '[] where
8889 allowScopes _ = []
8990
90−instance (KnownSymbol x, Allow xs) => Allow (x ': xs) where
91+instance (KnownSymbol x, AllowScopes xs) => AllowScopes (x ': xs) where
9192 allowScopes _ = scope (Proxy :: Proxy x) : allowScopes (Proxy :: Proxy xs)
9293 where
9394 scope = OAuthScope . Text.pack . symbolVal
9495
95−instance Allow s => Allow (Credentials s) where
96+instance AllowScopes s => AllowScopes (Credentials s) where
9697 allowScopes _ = allowScopes (Proxy :: Proxy s)
9798
9899concatScopes :: [OAuthScope] -> Text
gogol/src/Network/Google/Env.hs+2−2
@@ -121,14 +121,14 @@ timeout s = local (override (serviceTimeout ?~ s))
121121-- Lenses from 'HasEnv' can be used to further configure the resulting 'Env'.
122122--
123123-- /See:/ 'newEnvWith', 'getApplicationDefault'.
124−newEnv :: (MonadIO m, MonadCatch m, Allow s) => m (Env s)
124+newEnv :: (MonadIO m, MonadCatch m, AllowScopes s) => m (Env s)
125125newEnv = do
126126 m <- liftIO (newManager tlsManagerSettings)
127127 c <- getApplicationDefault m
128128 newEnvWith c (\_ _ -> pure ()) m
129129
130130-- /See:/ 'newEnv'.
131−newEnvWith :: (MonadIO m, MonadCatch m, Allow s)
131+newEnvWith :: (MonadIO m, MonadCatch m, AllowScopes s)
132132 => Credentials s
133133 -> Logger
134134 -> Manager