I was at first against this proposal by a knee jerk "but it isn't a string" response.
On 10 July 2013 05:24, Simon Hengel <sol@typeful.net> wrote:+1
> Hi,
> what about adding
>
> instance IsString a => IsString (Maybe a) where
> fromString = Just . fromString
>
> It makes specifying optional String/Text/... values more convenient.
> Here is an example that uses System.Process.shell:
>
> Use
>
> shell "ls -l" { cwd = "/home/me" }
>
> instead of
>
> shell "ls -l" { cwd = Just "/home/me" }
>
> I'm not yet sure how essential it is. But I somehow can't see any
> issues with it. So why not?
After reviewing the resulting discussion I agree that there's no
possible ambiguity and Simon's use-case is compelling. I think it's
great that this allows us to write obvious code without cluttering the
common use-case with Justs, while still allowing the underlying types
to be properly expressive (ie. admitting a Nothing value when that is
appropriate). This is especially important for a DSL that uses lots of
strings, like shell scripting.
I think (Maybe String) is a perfectly good string; it's just a string
type that has an extra value of Nothing -- and Nothing doesn't even
play a part in the IsString instance.
Conrad.
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries