Expose Elm types

As a general rule of thumb, internal values need no opaque types to hide their implementation
parser
Bram 2024-04-10 08:28:52 +02:00
parent c858ef151e
commit 203205f53c
2 changed files with 8 additions and 8 deletions

View File

@ -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 =

View File

@ -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 ":"