[ANNOUNCE] GHC 8.6.1-alpha2 available

Andrés Sicard-Ramírez asr at eafit.edu.co
Sat Jul 21 13:25:04 UTC 2018


Thank you for a very clear explanation and the solution.

Best,

On 21 July 2018 at 08:03, Ryan Scott <ryan.gl.scott at gmail.com> wrote:
> Presumably, you're compiling this program outside of a git repository,
> and so the Template Haskell splice $(gitHash) evaluates to "UNKNOWN"
> at compile time. Here is an even more minimal example, which does not
> depend on gitrev:
>
>     f :: ()
>     f = case "UNKNOWN" of
>           "UNKNOWN" -> ()
>           _         -> ()
>
> This, when compiled with GHC 8.6.1 or later, gives the same warning:
>
>     Test.hs:4:7: warning: [-Woverlapping-patterns]
>         Pattern match is redundant
>         In a case alternative: _ -> ...
>       |
>     4 |       _         -> ()
>       |       ^^^^^^^^^^^^^^^
>
> This, I would argue, is a correct error message. The string literal
> "UNKNOWN" is, well, statically known to be "UNKNOWN", so GHC knows
> that that catch-all case cannot be reached. (See [1] for the commit
> which introduced this check.)
>
> Granted, this makes things slightly inconvenient for your purposes,
> since in your actual program, $(gitHash) might evaluate to *different*
> things at compile time depending on the directory you compile it in.
> I'd recommend rewriting the commitInfo function to pattern guards:
>
>     commitInfo :: Maybe String
>     commitInfo
>       | hash == "UNKNOWN" = Nothing
>       | otherwise         = Just hash
>       where
>         hash = $(gitHash)
>
> Since that does not trigger -Woverlapping-patterns. (Granted, it's
> possible that GHC could become much smarter in the future and be able
> to detect that that `otherwise` case is unreachable when $(gitHash)
> evaluates to "UNKNOWN" at compile time. But GHC certainly isn't that
> smart today!)
>
> Ryan S.
> -----
> [1] http://git.haskell.org/ghc.git/commit/1f88f541aad1e36d01f22f9e71dfbc247e6558e2
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
> La información contenida en este correo electrónico está dirigida únicamente a su destinatario y puede contener información confidencial, material privilegiado o información protegida por derecho de autor. Está prohibida cualquier copia, utilización, indebida retención, modificación, difusión, distribución o reproducción total o parcial. Si usted recibe este mensaje por error, por favor contacte al remitente y elimínelo. La información aquí contenida es responsabilidad exclusiva de su remitente por lo tanto la Universidad EAFIT no se hace responsable de lo que el mensaje contenga. The information contained in this email is addressed to its recipient only and may contain confidential information, privileged material or information protected by copyright. Its prohibited any copy, use, improper retention, modification, dissemination, distribution or total or partial reproduction. If you receive this message by error, please contact the sender and delete it. The information contained herein is the sole responsibility of the sender therefore Universidad EAFIT is not responsible for what the message contains.



-- 
Andrés


More information about the ghc-devs mailing list