From b6e0ec4cda2f8b23da5b52f08ec7628d5b5ac0d7 Mon Sep 17 00:00:00 2001 From: Nikita Volkov Date: Tue, 3 Sep 2024 01:49:35 +0300 Subject: [PATCH] Export rendering functions --- library/Iri/Rendering/Text/Internal.hs | 48 +++++++++++++++++-- library/Iri/Rendering/TextBuilder/Internal.hs | 20 ++++++-- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/library/Iri/Rendering/Text/Internal.hs b/library/Iri/Rendering/Text/Internal.hs index a179ee2..258bd46 100644 --- a/library/Iri/Rendering/Text/Internal.hs +++ b/library/Iri/Rendering/Text/Internal.hs @@ -7,10 +7,50 @@ import Text.Builder qualified as B -- | Render as a Unicode IRI text iri :: Iri -> Text -iri = - B.run . A.iri +iri = B.run . A.iri -- | Render as a Unicode IRI text httpIri :: HttpIri -> Text -httpIri = - B.run . A.httpIri +httpIri = B.run . A.httpIri + +scheme :: Scheme -> Text +scheme = B.run . A.scheme + +hierarchy :: Hierarchy -> Text +hierarchy = B.run . A.hierarchy + +authority :: Authority -> Text +authority = B.run . A.authority + +userInfo :: UserInfo -> Text +userInfo = B.run . A.userInfo + +host :: Host -> Text +host = B.run . A.host + +regName :: RegName -> Text +regName = B.run . A.regName + +domainLabel :: DomainLabel -> Text +domainLabel = B.run . A.domainLabel + +ipV4 :: IPv4 -> Text +ipV4 = B.run . A.ipV4 + +ipV6 :: IPv6 -> Text +ipV6 = B.run . A.ipV6 + +port :: Port -> Text +port = B.run . A.port + +path :: Path -> Text +path = B.run . A.path + +pathSegment :: PathSegment -> Text +pathSegment = B.run . A.pathSegment + +query :: Query -> Text +query = B.run . A.query + +fragment :: Fragment -> Text +fragment = B.run . A.fragment diff --git a/library/Iri/Rendering/TextBuilder/Internal.hs b/library/Iri/Rendering/TextBuilder/Internal.hs index f7ed5a9..8ba386f 100644 --- a/library/Iri/Rendering/TextBuilder/Internal.hs +++ b/library/Iri/Rendering/TextBuilder/Internal.hs @@ -1,6 +1,20 @@ module Iri.Rendering.TextBuilder.Internal ( iri, httpIri, + scheme, + hierarchy, + authority, + userInfo, + host, + regName, + domainLabel, + ipV4, + ipV6, + port, + path, + pathSegment, + query, + fragment, ) where @@ -77,12 +91,12 @@ userInfoComponent = host :: Host -> Builder host = \case - NamedHost value -> domainName value + NamedHost value -> regName value IpV4Host value -> ipV4 value IpV6Host value -> ipV6 value -domainName :: RegName -> Builder -domainName (RegName vector) = +regName :: RegName -> Builder +regName (RegName vector) = F.intercalate domainLabel (char '.') vector domainLabel :: DomainLabel -> Builder