From 203205f53cafff6844b881b95f016b5aac8c9bd8 Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 10 Apr 2024 08:28:52 +0200 Subject: [PATCH] Expose Elm types As a general rule of thumb, internal values need no opaque types to hide their implementation --- src/Internal/Grammar/ServerName.elm | 8 ++++---- src/Internal/Grammar/UserId.elm | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Internal/Grammar/ServerName.elm b/src/Internal/Grammar/ServerName.elm index 1ee3cff..b61e913 100644 --- a/src/Internal/Grammar/ServerName.elm +++ b/src/Internal/Grammar/ServerName.elm @@ -47,8 +47,8 @@ type alias IPv6Address = {-| The server name is a combination of a hostname and an optional port. -} -type ServerName - = ServerName { host : HostName, port_ : Maybe Int } +type alias ServerName = + { host : HostName, port_ : Maybe Int } {-| Parser for the DNS name record. The Matrix spec bases its grammar on the @@ -214,7 +214,7 @@ portParser = servernameParser : Parser ServerName servernameParser = - P.succeed (\h p -> ServerName { host = h, port_ = p }) + P.succeed ServerName |= hostnameParser |= P.oneOf [ P.succeed Just @@ -225,7 +225,7 @@ servernameParser = toString : ServerName -> String -toString (ServerName { host, port_ }) = +toString { host, port_ } = let hostString : String hostString = diff --git a/src/Internal/Grammar/UserId.elm b/src/Internal/Grammar/UserId.elm index be433ba..2a2327f 100644 --- a/src/Internal/Grammar/UserId.elm +++ b/src/Internal/Grammar/UserId.elm @@ -43,8 +43,8 @@ import Internal.Tools.ParserExtra as PE import Parser as P exposing ((|.), (|=), Parser) -type UserID - = UserID { localpart : String, domain : ServerName } +type alias UserID = + { localpart : String, domain : ServerName } fromString : String -> Maybe UserID @@ -61,13 +61,13 @@ localpartParser = toString : UserID -> String -toString (UserID { localpart, domain }) = +toString { localpart, domain } = String.concat [ "@", localpart, ":", ServerName.toString domain ] userIdParser : Parser UserID userIdParser = - P.succeed (\l d -> UserID { localpart = l, domain = d }) + P.succeed UserID |. P.symbol "@" |= localpartParser |. P.symbol ":"