Reputation: 2089
I am trying to use the smtp-mail module.
I am trying to construct the Address
data type which is of:
Address
addressName :: Maybe Text
addressEmail :: Text
with overloaded strings I can construct the Address
no problem. However when I try to pass a String to it and pack
it, I cannot seem to find the correct pack
function.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.Lazy as T
import Network.Mail.SMTP
testAddress :: String
testAddress = "[email protected]"
-- this works fine
myAddress1 :: Address
myAddress1 = Address Nothing ("[email protected]")
myAddress2 :: Address
myAddress2 = Address Nothing (T.pack testAddress)
gives error:
* Couldn't match expected type `Data.Text.Internal.Text'
with actual type `T.Text'
NB: `T.Text' is defined in `Data.Text.Internal.Lazy'
`Data.Text.Internal.Text' is defined in `Data.Text.Internal'
* In the second argument of `Address', namely
`(T.pack testAddress)'
In the expression: Address Nothing (T.pack testAddress)
In an equation for `myAddress2':
myAddress2 = Address Nothing (T.pack testAddress)
Upvotes: 1
Views: 330
Reputation: 1743
you seem to be using Data.Text.Lazy
but after testing it out, as recommended by @melpomene you need to change:
--import qualified Data.Text.Lazy as T
import qualified Data.Text as T
if you look at the Address
definition it expects a Text
to be from Data.Text
https://hackage.haskell.org/package/smtp-mail-0.1.4.6/docs/Network-Mail-SMTP-Types.html#t:Address
Upvotes: 1