Skip to content

Commit

Permalink
Fix tests for GHC 9.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges committed Mar 20, 2022
1 parent 59eb86a commit dc6a7b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/Text/Email/QuasiQuotation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import Text.Email.Validate (validate, localPart, domainPart, unsafeEmailAddress)

-- | A QuasiQuoter for email addresses.
--
-- Use it like this:
-- Use it like this (requires `QuasiQuotes` to be enabled):
--
-- >>> :set -XQuasiQuotes
-- >>> [email|[email protected]|]
-- "[email protected]"
email :: QuasiQuoter
Expand Down
10 changes: 2 additions & 8 deletions src/Text/Email/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ import Text.Email.Parser
, toByteString
, unsafeEmailAddress)

-- $setup
-- This is required for all examples:
--
-- >>> :set -XOverloadedStrings

-- | Smart constructor for an email address
emailAddress :: ByteString -> Maybe EmailAddress
emailAddress = either (const Nothing) Just . validate

-- | Checks that an email is valid and returns a version of it
-- where comments and whitespace have been removed.
--
-- Example:
-- Example (requires `OverloadedStrings` to be enabled):
--
-- >>> canonicalizeEmail "spaces. are. [email protected]"
-- Just "[email protected]"
Expand All @@ -51,7 +46,7 @@ isValid = either (const False) (const True) . validate
-- | If you want to find out *why* a particular string is not
-- an email address, use this.
--
-- Examples:
-- Examples (both require `OverloadedStrings` to be enabled):
--
-- >>> validate "[email protected]"
-- Right "[email protected]"
Expand All @@ -60,4 +55,3 @@ isValid = either (const False) (const True) . validate
-- Left "at sign > @: not enough input"
validate :: ByteString -> Either String EmailAddress
validate = parseOnly (addrSpec >>= \r -> endOfInput >> return r)

2 changes: 2 additions & 0 deletions tests/doctests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ main = doctest
[ "-isrc"
, "src/Text/Email/QuasiQuotation.hs"
, "src/Text/Email/Validate.hs"
, "-XQuasiQuotes"
, "-XOverloadedStrings"
]

0 comments on commit dc6a7b3

Please sign in to comment.