Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ghc does not report non-exhaustive pattern matches when using the `no-code` flag

I tend to repeatedly typecheck my programs in a terminal whilst modifying them in my editor of choice in order to get real-time feedback. I typically run something akin to: watch -d -n 1 "ghc -fno-code NoIncompletePM.hs".

Unfortunately the no-code flag which I use to avoid compiling again and again code I don't care about yet seems to be incompatible with the warn-incomplete-patterns one. E.g. with this program:

{-# OPTIONS  -Wall             #-}
module NoIncompletePM where

argh :: Bool -> Bool
argh True = True

I never get any warning that argh is missing a case for False. It is possible to get all of these warnings by removing the no-code flag and adding the force-recomp one (so that the warning is displayed every single time and not just the first time it's compiled) but I precisely want to avoid compiling this code...

I could not find anything in the manual describing these as being incompatible so I'm guessing that it's either an unexpected behaviour or I am doing something wrong. Any clues?

like image 499
gallais Avatar asked Nov 10 '22 21:11

gallais


1 Answers

This is a known ghc bug:

https://ghc.haskell.org/trac/ghc/ticket/8101

Note that if you pass the -c flag for one-shot mode, then you do get warnings. So that's a workaround for now.

Sadly, it appears (https://ghc.haskell.org/trac/ghc/ticket/10600) that ghc 8.0 may rebreak this working even in one-shot mode, at least for one more release cycle.

like image 193
sclv Avatar answered Nov 15 '22 06:11

sclv