Proposal: Add IsString instance for (Maybe a) to base

Ben Millwood haskell at benmachine.co.uk
Sun Jul 14 02:44:25 CEST 2013


On Fri, Jul 12, 2013 at 01:29:43PM +0300, Roman Cheplyaka wrote:
>* John Lato <jwlato at gmail.com> [2013-07-12 17:03:03+0800]
>> In all seriousness, I'm not that fond of the proposal myself.  I just
>> wanted to argue the other side because nobody else was.  But so far, I've
>> seen two main arguments against the proposal:
>>
>> 1.  IsString is for things that are notionally some sort of string.
>> 2.  It makes the types more confusing.
>>
>> The second seems like a weak argument to me.  First off, the proposal seems
>> very similar to the recent generalization of Prelude.map, which had a great
>> deal of support.
>
>The difference is that fromString is called implicitly.
>
>A similar precedent is numeric literals. When I type 1, a method is
>called, but most of the time I don't need to think about it because
>those methods agree with my intuitive semantics of numbers.
>
>It's easy to define a more or less proper instance
>
>  instance (Applicative t, Num n) => Num (t n)
>
>which would allow to overload numbers even harder, but then I'd need to
>stop and think every time I see a number.
>
>Roman

I agree. When I see a string literal in the source code of a program, I 
want to be able to think of it as, well, a string. Not necessarily a 
String with a capital S, but a string of some sort nonetheless. A Maybe 
String is no such thing! The idea is only slightly less ridiculous than 
having a literal denote its singleton list, or singleton set, or tree 
with one leaf.

(so -1 from me)



More information about the Libraries mailing list