module Network.OAuth2.Experiment.Utils where import Data.Bifunctor import Data.ByteString (ByteString) import Data.ByteString.Char8 qualified as BS8 import Data.Map.Strict (Map) import Data.Map.Strict qualified as Map import Data.Text qualified as T import Data.Text.Encoding qualified as T import Data.Text.Encoding qualified as TE import Data.Text.Lazy qualified as TL import URI.ByteString (URI, serializeURIRef') tlToBS :: TL.Text -> ByteString tlToBS :: Text -> ByteString tlToBS = Text -> ByteString TE.encodeUtf8 forall b c a. (b -> c) -> (a -> b) -> a -> c . Text -> Text TL.toStrict bs8ToLazyText :: BS8.ByteString -> TL.Text bs8ToLazyText :: ByteString -> Text bs8ToLazyText = String -> Text TL.pack forall b c a. (b -> c) -> (a -> b) -> a -> c . ByteString -> String BS8.unpack unionMapsToQueryParams :: [Map TL.Text TL.Text] -> [(ByteString, ByteString)] unionMapsToQueryParams :: [Map Text Text] -> [(ByteString, ByteString)] unionMapsToQueryParams = forall a b. (a -> b) -> [a] -> [b] map (forall (p :: * -> * -> *) a b c d. Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d bimap Text -> ByteString tlToBS Text -> ByteString tlToBS) forall b c a. (b -> c) -> (a -> b) -> a -> c . forall k a. Map k a -> [(k, a)] Map.toList forall b c a. (b -> c) -> (a -> b) -> a -> c . forall (f :: * -> *) k a. (Foldable f, Ord k) => f (Map k a) -> Map k a Map.unions uriToText :: URI -> T.Text uriToText :: URI -> Text uriToText = ByteString -> Text T.decodeUtf8 forall b c a. (b -> c) -> (a -> b) -> a -> c . forall a. URIRef a -> ByteString serializeURIRef'