` {-# MINIMAL f, g | () #-}` pragma doesn't work as expected
Summary
import Data.Proxy (Proxy)
import Data.Kind (Type)
-- law: \a -> poly a (root a) ≡ 0
class C (a :: Type) where
poly :: Proxy a -> Double -> Double
poly _ x = 2 * x + 5
root :: Proxy a -> Double
root _ = -2.5
{-# MINIMAL poly, root | () #-}
data A
instance C A where
poly _ x = x + 5
-- gives warning correctly because of missing `root`
-- root _ = -5
data B
--- shouldn't give warning
instance C B
The ()
should mean that giving no definitions should also give no warnings.
This is necessary in cases like this where you have laws that involve multiple members
of the class.
Steps to reproduce
Compile the above code. You get
Test.hs:20:10: warning: [-Wmissing-methods]
• No explicit implementation for
either (‘poly’ and ‘root’) or ‘()’
• In the instance declaration for ‘C B’
|
20 | instance C B
Expected behavior
There should be no warning on B
.
Environment
- GHC version used: 9.2.2
Optional:
- Operating System: NixOS
- System Architecture: aarch64-linux
On Discourse: https://discourse.haskell.org/t/minimal-f-g/4697