on develop help sign in
Documentation
commitecf0dd41fe2ceca9127c2ed19b2abc2c3f8775f3 authorBrendan Hay <brendan.g.hay@gmail.com> dateSat 31 Oct 2015, 16:11 (11 years ago) parent752af3d
1 file changed+11−8
gogol/src/Network/Google/Auth/Scope.hs+11−8
gogol/src/Network/Google/Auth/Scope.hs+11−8
@@ -35,17 +35,19 @@ import Network.Google.Prelude (GoogleRequest (..),
3535 OAuthScope (..))
3636import Network.HTTP.Types (urlEncode)
3737
38−-- | Type-restrict the supplied credentials/whatever to the specific scopes.
38+-- | Type-restrict the supplied credentials etc. to the specific scopes.
3939--
40−-- This simply exists to allow users to choose between 'getCredentials' and
41−-- 'getCredentialsP' styles, without having the two separate functions.
40+-- This simply exists to allow users to choose between using 'getCredentials'
41+-- with a 'Proxy' type, or explicitly specifying the type annotation without
42+-- having separate functions.
4243--
4344-- This seems sufficiently general, does it already exist?
4445--
45−-- /See:/ '(!)'.
46+-- /See:/ '!'.
4647allow :: proxy s -> k s -> k s
4748allow _ = id
4849
50+-- | Type-restrict the supplied credentials etc. to no scopes.
4951forbid :: k '[] -> k '[]
5052forbid = id
5153
@@ -61,11 +63,12 @@ forbid = id
6163-- For error message/presentation purposes, this wraps the result of
6264-- the membership checks below.
6365type family Authorize (s :: [Symbol]) a :: Constraint where
64− Authorize s a = MatchAnyScope (Scopes a) s ~ 'True
66+ Authorize s a = MatchAnyScope s (Scopes a) ~ 'True
6567
66−type family MatchAnyScope a s where
67− MatchAnyScope '[] s = 'True
68− MatchAnyScope a (x ': xs) = x ∈ a || MatchAnyScope a xs
68+-- | Check if any scope exists in both parameters.
69+type family MatchAnyScope a b where
70+ MatchAnyScope a '[] = 'True
71+ MatchAnyScope (x ': xs) b = x ∈ b || MatchAnyScope xs b
6972
7073-- | Set membership.
7174type family (∈) a b where