@@ -41,13 +41,11 @@ import Network.HTTP.Types (urlEncode)
4141-- with a 'Proxy' type, or explicitly specifying the type annotation without
4242-- having separate functions.
4343--
44−-- This seems sufficiently general, does it already exist?
45−--
4644-- /See:/ '!'.
4745allow :: proxy s -> k s -> k s
4846allow _ = id
4947
50−-- | Type-restrict the supplied credentials etc. to no scopes.
48+-- | Type-restrict the supplied credentials (etc.) to no scopes.
5149forbid :: k '[] -> k '[]
5250forbid = id
5351
@@ -61,16 +59,17 @@ forbid = id
6159-- listed in the scopes the credentials supports.
6260--
6361-- For error message/presentation purposes, this wraps the result of
64−-- the membership checks below.
65−type family Authorize (s :: [Symbol]) a :: Constraint where
66− Authorize s a = MatchAnyScope s (Scopes a) ~ 'True
62+-- the 'HasScope' membership check to show both lists of scopes before
63+-- reduction.
64+type family HasScope (s :: [Symbol]) a :: Constraint where
65+ HasScope s a = (s `HasScope'` Scopes a) ~ 'True
6766
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
67+-- | Check if any of actual supplied scopes 's' exist in the required set 'a'.
68+type family HasScope' s a where
69+ HasScope' s '[] = 'True -- No scopes are required.
70+ HasScope' (x ': xs) a = x ∈ a || HasScope' xs a
7271
73−-- | Set membership.
72+-- | Membership.
7473type family (∈) a b where
7574 (∈) x '[] = 'False
7675 (∈) x (y ': xs) = x == y || x ∈ xs
@@ -82,19 +81,19 @@ type family (++) xs ys where
8281 (++) (a ': as) bs = a ': (as ++ bs)
8382
8483class Allow a where
85− -- | Obtain a list of supported 'OAuthScope's from a proxy type.
86− getScopes :: proxy a -> [OAuthScope]
84+ -- | Obtain a list of supported 'OAuthScope' values from a proxy.
85+ allowScopes :: proxy a -> [OAuthScope]
8786
8887instance Allow '[] where
89− getScopes _ = []
88+ allowScopes _ = []
9089
9190instance (KnownSymbol x, Allow xs) => Allow (x ': xs) where
92− getScopes _ = scope (Proxy :: Proxy x) : getScopes (Proxy :: Proxy xs)
91+ allowScopes _ = scope (Proxy :: Proxy x) : allowScopes (Proxy :: Proxy xs)
9392 where
9493 scope = OAuthScope . Text.pack . symbolVal
9594
9695instance Allow s => Allow (Credentials s) where
97− getScopes _ = getScopes (Proxy :: Proxy s)
96+ allowScopes _ = allowScopes (Proxy :: Proxy s)
9897
9998concatScopes :: [OAuthScope] -> Text
10099concatScopes = Text.intercalate " " . coerce