4 ms·
I am confused, the text says: > The subject of the mail will change based on the status of the Reservation. With the type system in place, the compiler makes s
by phaer 5y ago
I am confused, the text says:
> The subject of the mail will change based on the status of the Reservation. With the type system in place, the compiler makes sure we that do not forget any possible case.
But the [linked code](https://github.com/Gizra/ihp-simple-seat-reservation/blob/f9a9c57eec8f02526beb24201d3125025a23e69b/Web/Mail/Reservations/Confirmation.hs#L12-L18 https://github.com/Gizra/ihp-simple-seat-reservation/blob/f9...) seems to include a wildcard clause which would just set the subject to an empty string. Am I missing something?
- HowardStark 5y agoThe important point isn’t that there’s a wild card, it’s that there isn’t an undefined clause. You know with compiler-assured certainty that WYSIWYG, which is a big step in code predictability.
- phaer 5y agoCould you elaborate? Wouldn't it be better to i.e. throw a runtime error than to send an email with an empty subject to a user from a business perspective in most cases?
- amitaibu 5y agoI tried to keep the code simple, so yeah - it was on the expense of making it more "right". In this case I wouldn't call the command send the mail unless status was explicitly Accepted or Rejected. But as notes above, the important part is that the compiler doesn't let me forget about all the possible cases (e.g. `Queue` in this example).