Skip to content

Commit

Permalink
Export rendering functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-volkov committed Sep 2, 2024
1 parent 152b331 commit b6e0ec4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
48 changes: 44 additions & 4 deletions library/Iri/Rendering/Text/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 17 additions & 3 deletions library/Iri/Rendering/TextBuilder/Internal.hs
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b6e0ec4

Please sign in to comment.