[darcs-users] DrHaskell report for darcs

Neil Mitchell ndmitchell at gmail.com
Tue Dec 16 20:14:45 UTC 2008


Hi

Before starting, I should say that I agree that some of the hints
aren't universally applicable.

> Whether "Eta reduce" makes sense or not varies on a case-by-case basis,
> IMO. The question is mostly, "which is easiest to read and understand?".

I particularly agree about this one, I'm still trying to see if there
is a general rule behind it or not...

> "Use (:)" depends on context IMO. I'd generally use "xs ++ [y] ++ zs"
> rather than "xs ++ y:zs".

Me too. Note that if you do xs ++ [y] ++ zs it _won't_ suggest to use
(:) - since it recognises that the symetry looks nice :-)


> "Use isPrefixOf", I think the tool should recognise constants specially.
> So
>    take 4 (just_name pinfo) == "TAG "
> =>
>    "TAG " `isPrefixOf` just_name pinfo
> and
>    take 4 (just_name pinfo) == "TAG"
> is complained about loudly.

It would be nice, but didn't get implemented yet.

> If the RHS isn't a constant then the suggested replacement behaves
> differently: It evaluates the entire spine of the RHS, whereas the
> original only evaluates the necessary prefix.

It won't suggest unless the RHS is a constant, I think...

> "Redundant if", yup, but the tool has added some redundant parentheses.

Spotted that this morning too, if you add the parentheses it will then
suggest you have redundant bracketing - it doesn't always reach a
fixed point :-)

> "Use a list comprehension" I'm not convinced isn't an obfuscation.
> Again, the tool has added redundant parentheses.

Colin does it, I think it looks cool :-) I find it a cool pattern, but
others can sensibly disagree.

> "Use head": The first case:
>    argv !! 0 == "-h" || argv !! 0
> =>
>    head (argv !! 0 == "-h" || argv)
> is a bug, but otherwise agree.

The operator precedence in haskell-src-exts is wrong, which is what
has caused this.

Thanks for the comments,

Neil


More information about the darcs-users mailing list