@@ -35,17 +35,19 @@ import Network.Google.Prelude (GoogleRequest (..),
35 OAuthScope (..))
35 OAuthScope (..))
36import Network.HTTP.Types (urlEncode)
36import Network.HTTP.Types (urlEncode)
38−-- | Type-restrict the supplied credentials/whatever to the specific scopes.
38+-- | Type-restrict the supplied credentials etc. to the specific scopes.
40−-- This simply exists to allow users to choose between 'getCredentials' and
40+-- This simply exists to allow users to choose between using 'getCredentials'
41+-- with a 'Proxy' type, or explicitly specifying the type annotation without
41−-- 'getCredentialsP' styles, without having the two separate functions.
42+-- having separate functions.
43-- This seems sufficiently general, does it already exist?
44-- This seems sufficiently general, does it already exist?
45−-- /See:/ '(!)'.
46+-- /See:/ '!'.
46allow :: proxy s -> k s -> k s
47allow :: proxy s -> k s -> k s
47allow _ = id
48allow _ = id
50+-- | Type-restrict the supplied credentials etc. to no scopes.
49forbid :: k '[] -> k '[]
51forbid :: k '[] -> k '[]
50forbid = id
52forbid = id
@@ -61,11 +63,12 @@ forbid = id
61-- For error message/presentation purposes, this wraps the result of
63-- For error message/presentation purposes, this wraps the result of
62-- the membership checks below.
64-- the membership checks below.
63type family Authorize (s :: [Symbol]) a :: Constraint where
65type 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
68+-- | Check if any scope exists in both parameters.
66−type family MatchAnyScope a s where
69+type family MatchAnyScope a b where
67− MatchAnyScope '[] s = 'True
70+ MatchAnyScope a '[] = 'True
68− MatchAnyScope a (x ': xs) = x ∈ a || MatchAnyScope a xs
71+ MatchAnyScope (x ': xs) b = x ∈ b || MatchAnyScope xs b
70-- | Set membership.
73-- | Set membership.
71type family (∈) a b where
74type family (∈) a b where