Proposal: Add IsString instance for (Maybe a) to base
Henning Thielemann
lemming at henning-thielemann.de
Mon Jul 15 17:24:28 CEST 2013
On Mon, 15 Jul 2013, MightyByte wrote:
> I'll just throw out a data point related to this discussion. In one of my previous commercial Haskell
> projects we ended up writing a similar Num instance for Maybe a. I think I asked about it in #haskell back
> then and got pretty vocal distaste about the idea from several people who spoke up. "Maybe is not a
> number!" But we did end up using the instance in our project because it greatly simplified a section of our
> code.
I also had this analogy in mind. Looks like syntactic heroin.
Like (IsString (Maybe String)) does not fulfill intuitive laws, (Num
(Maybe a)) does not, too. E.g. if in your code you see 'a+b-b' you would
like to simplify that to 'a'. With a Maybe instance this is not true in
case 'b' is Nothing.
> I'm certainly not going to recommend that we also add the Num instance
> for Maybe. But I think it's a useful data point that this happened in
> real-world production code at a company where writing Haskell code was
> my full-time job.
This confirms that real world code contains a lot of mess.
More information about the Libraries
mailing list