On Fri, Jul 12, 2013 at 2:13 PM, Roman Cheplyaka <roma@ro-che.info> wrote:
* John Lato <jwlato@gmail.com> [2013-07-12 13:56:31+0800]
> The programmer is being explicit; the type specifies the value is a Maybe.
>  If it weren't, the Just wouldn't be inserted.

Not necessarily — take Simon's original example:

  (shell "ls -l") { cwd = "/home/me" }

If I didn't know the type of 'cwd', it would never occur to me while
reading this code that you can supply Nothing there.

So?  If you're just reading the code, it doesn't matter.  If you want to modify the code, presumably you would want to examine CreateProcess to at least get a glimpse of the types of fields.  And if you wanted to modify the code to use the default value, I think a natural instinct would be to just do

    (shell "ls -l")

which again would do the right thing.

Also, the fact that you can omit Just with string literals but not with
string values or values of other types creates an unnecessary
irregularity in the language.

OverloadedStrings (and number literals) are already a mess for this.  Currently, we have

    (shell "ls -l") { cwd = Just "/home/me" }

If I want to replace that literal with a value and I don't know the type of 'cwd', I already need to look it up.  Otherwise I might try to do something like this:

    dirFromUser <- Text.getLine
    (shell "ls -l") { cwd = Just dirFromUser }

and get a type error because it's expecting a Maybe String, not a Maybe Text.  This happens to me very frequently, unless I remember to look up the record/function/whatever first to see what type is expected.

I don't think adding a Just is any different from this situation.  In either case, if you know the type of the thing you'll get the changes correct.  If you don't know the type you're likely to either get it wrong or have to look it up.  But as usual, the type makes it completely clear.

A decent IDE helps a lot if you don't know the types of things in your code.  Everyone should use one.

Also, one nice thing about OverloadedStrings is that this doesn't need to be baked in.  A library with a few orphan instances along these lines could easily be provided separately.