[Haskell-cafe] -fdefer-type-errors

Bill Hallahan william.hallahan at yale.edu
Wed Apr 17 20:17:17 UTC 2019


Hi,

I'm trying to use the -fdefer-type-error flag, discussed in  an ICFP paper from 2012:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.366.841&rep=rep1&type=pdf <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.366.841&rep=rep1&type=pdf> 

On page 2, the paper has an example, showing that fdefer-type-errors will allow a the first element to be extracted fro a tuple, even if the second element does not correctly typecheck:

 ghci> let foo = (True, ’a’ && False)
 Warning: Couldn’t match ‘Bool’ with ‘Char’
 ghci> :type foo
 (Bool, Bool)
 ghci> fst foo
 True
However, with GHC 8.2.2, I get an error when trying to do this:
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Prelude> let foo = (True, 'a' && False)

<interactive>:1:18: warning: [-Wdeferred-type-errors]
    • Couldn't match expected type ‘Bool’ with actual type ‘Char’
    • In the first argument of ‘(&&)’, namely ‘'a'’
      In the expression: 'a' && False
      In the expression: (True, 'a' && False)
Prelude> :type foo
foo :: (Bool, Bool)
Prelude> fst foo
*** Exception: <interactive>:1:18: error:
    • Couldn't match expected type ‘Bool’ with actual type ‘Char’
    • In the first argument of ‘(&&)’, namely ‘'a'’
      In the expression: 'a' && False
      In the expression: (True, 'a' && False)
(deferred type error)

Does anyone know the reason for the change in the behavior?  Is there any way to get back to the old behavior, i.e. allow the first element of the tuple to still be extracted?  Ideally, I would like to get the errors given by defer-type-errors to be as fine-grained/close-to-the-source as possible.

Thanks,
Bill Hallahan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190417/3faa3ec1/attachment.html>


More information about the Haskell-Cafe mailing list