Skip to content

incorrect type-defaults warning for lambda expressions

Summary

incorrect type-defaults warning for lambda expressions

Steps to reproduce

load a file containing

{-# OPTIONS_GHC -Wtype-defaults #-}  
square = (\x -> x * x)  
square2 x = x * x  

You will get the following:

alcm.hs:6:17: warning: [-Wtype-defaults]
• Defaulting the following constraint to type ‘Integer’
Num a0 arising from a use of ‘*’
• In the expression: x * x
In the expression: (\ x -> x * x)
In an equation for ‘square’: square = (\ x -> x * x)
|
6 | square = (\x -> x * x)
|

Expected behavior

There should be no warning for square just as there is no warning for square2

Environment

  • GHC version used: 8.6.5

Optional:

  • Operating System: MacOS 10.14.4
  • System Architecture:
Edited by george.colpitts
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information