Comments (3)
sendMailCustom isn't partial, it throws an exception when something exceptional occurs. This is standard practice in Haskell across many libraries, including base (take readFile
, for instance). I am in favor of improving this package so that it throws a proper exception type instead of using error
. But exception usage in Haskell is pervasive. If you want to change that, it's a far bigger task than adding a function to this package.
from mime-mail.
Ok, so it's not partial by a strict "over-all-input" definition, but still the function can evaluate to ⊥ which is more the problem I'm getting at. I'm aware that this is the current general practice in Haskell, but I don't think that's a reason we can't offer a non-throwing version (perhaps alongside one that does throw). I'm not looking like to change how all of Haskell works, though when I encounter problems where I would prefer a real error type, I do raise tickets :)
from mime-mail.
Nope, it can't:
{-# LANGUAGE BangPatterns #-}
import Control.Exception
import Network.Mail.Mime
main :: IO ()
main = do
_ <- evaluate $ sendmail undefined
putStrLn "Not partial"
!_ <- evaluate $ sendmail undefined
putStrLn "Still not partial"
_ <- evaluate undefined
putStrLn "Yep, that's partial"
Part of the contract of IO
is that it can throw exceptions. sendmail
itself will throw an exception if the sendmail process returns an failure exit code. But that's not the only way. Consider this seemingly safe code:
import Network.Mail.Mime
import Data.ByteString.Lazy.Char8 (pack)
main :: IO ()
main = sendmail $ pack "To: [email protected]\r\nSubject: test\r\n\r\nThis is a test"
Run it on a system without the sendmail executable, and you get:
foo.hs: fd:9: hClose: resource vanished (Broken pipe)
There are many other things that can go wrong: incorrect permissions, too many open file handles, etc.
In other words: no matter what you need to take exceptions into account. Changing the sendmail function's behavior won't change the fact that you're in IO, and you have to respect the contract that it might throw an exception. Making this change would imply something which isn't true.
from mime-mail.
Related Issues (20)
- Search sendmail binary on path HOT 2
- Emails get delivered to the wrong address
- generate wrong message HOT 3
- convenience functions for constructing a mail HOT 1
- return type of sendMailSES HOT 6
- bcc is not working HOT 5
- SES: Sending Mail From Different Regions HOT 2
- renderMail' called with null parts, even though multiple parts specified HOT 5
- Network.Mail.Mime.SES does not export SESException HOT 2
- multipart/related support HOT 12
- Mails might become truncated because of inserted newlines. HOT 7
- Add `IsString` instance for `Address`? HOT 1
- Proper way to set Content-ID of an attachment HOT 3
- malformed `From:` and `To:` headers:
- Space in filename causes error when using mime-mail-ses HOT 5
- Add another function named `sendMailSES'` HOT 4
- Length of `encoded-words` HOT 1
- Eq instace for Mail HOT 1
- Use AWS signature version 4 (required starting October 2020) HOT 8
- Function that parses an RFC5322 email address string HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mime-mail.