Question
What does it mean in Haskell when a function doesn't handle every constructor of a data type?
Consider
data Pair = Pair (Headers, Builder)
| CompoundPair (Headers, [Pair])
showBoundPart :: Boundary -> Pair -> Builder
showBoundPart (Boundary b) (Pair (headers, content)) = mconcat
[ fromByteString "--"
, fromText b
, fromByteString "\n"
, mconcat $ map showHeader headers
, fromByteString "\n"
, content
]
Observe that Pair is a sum type, but that showBoundPart does not handle CompoundPair
, only Pair
.
I come from another language where this is a compile-time error, but this code is lifted from the MimeMail library, which is presumably in production somewhere. https://hackage.haskell.org/package/mime-mail-0.5.1/docs/src/Network.Mail.Mime.html#Part