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

John Lato jwlato at gmail.com
Fri Jul 12 03:36:04 CEST 2013


I wasn't suggesting that we actually include that instance, just using it
to demonstrate the form.


On Fri, Jul 12, 2013 at 9:32 AM, Edward A Kmett <ekmett at gmail.com> wrote:

> Even if we wanted to we cannot use that as an actual instance.
>
> It conflicts with the most important IsString instance of all: String!
>
> Sent from my iPhone
>
> On Jul 11, 2013, at 9:20 PM, Carter Schonwald <carter.schonwald at gmail.com>
> wrote:
>
> ok, framed, that way, the proposal seems much more reasonable.
>
> When framed wrt Maybe, I immediately think "nullable values", though now
> that I think about it more, any use of IsString there would always be  f
> a =  Just a, so even then, its philosophically kosher.
>
> I withdraw my -1, at least for the applicative version
>
>
> On Thu, Jul 11, 2013 at 8:19 PM, John Lato <jwlato at gmail.com> wrote:
>
>> To play devil's advocate, why?
>>
>> What does limiting IsString in this fashion gain anyone?  It doesn't
>> complicate type inference any more than it already is.  For any
>> applicative, there's the trivial instance
>>
>> instance (IsString a, Applicative t) => IsString (t a) where
>>     fromString = pure . fromString
>>
>> which is conceptually a very simple step and is always total.
>>
>> Of course some functors admit other instances.  I think some parser
>> libraries already provide IsString instances as a nice syntax on matching
>> string literals.  A rule like this would invalidate those instances for no
>> particularly good reason I can see.
>>
>>
>> On Fri, Jul 12, 2013 at 4:22 AM, Sjoerd Visscher <sjoerd at w3future.com>wrote:
>>
>>> Could this be formalised by saying that there should be a function
>>> toString such that
>>>
>>>   fromString . toString = id
>>>
>>> There's no such toString for "Maybe a" with fromString = Just.
>>>
>>> Sjoerd
>>>
>>> On Jul 10, 2013, at 4:02 PM, David Luposchainsky <
>>> dluposchainsky at googlemail.com> wrote:
>>>
>>> > On 2013-07-10 15:55, Joachim Breitner wrote:
>>> >> Hi,
>>> >>
>>> >> Am Mittwoch, den 10.07.2013, 09:21 +1000 schrieb Ivan Lazar
>>> Miljenovic:
>>> >>> -0.5 from me; I think it's too easy to forget that it's a Maybe value
>>> >>> there when refactoring, etc.
>>> >>
>>> >> same here; even with OverloadedStrings Haskell should feel as strongly
>>> >> typed as it is.
>>> >
>>> > Agreed. Overloaded strings should be reserved for things that *are*
>>> > strings in a certain way. A "Maybe String" is not a special way of
>>> > storing a string (like for example a "Vector Char"), it's a String with
>>> > an additional value. Providing a Maybe instance goes too far in the
>>> > direction of having a general "'return' with strings" function, so I'm
>>> > -1 on this.
>>> >
>>> > David
>>> >
>>> >
>>> > _______________________________________________
>>> > Libraries mailing list
>>> > Libraries at haskell.org
>>> > http://www.haskell.org/mailman/listinfo/libraries
>>>
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://www.haskell.org/mailman/listinfo/libraries
>>>
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130712/20d8de43/attachment.htm>


More information about the Libraries mailing list