====== Annotation for a minimal complete definition ======
~~DISCUSSION~~
Format:{-# MINIMAL function1 | function2 #-}
Minimal pragmas are boolean expressions. For instance, with | as logical OR, either definition of the above functions must be defined. Comma indicates logical AND where both definitions must be defined.
See also: [[http://dev.stephendiehl.com/hask/#minimal-annotations|External Link]]
===== Example =====
{-# LANGUAGE GADTs #-}
module Main where
main :: IO ()
main =
do
print x
data MayBe' a
where
Just' :: Eq a => a -> MayBe' a
Nothing' :: Eq a => MayBe' a
class Eq' a where
(===) :: a -> a -> Bool
(/==) :: a -> a -> Bool
(===) x y = not (x /== y)
x /== y = not (x === y)
{-# MINIMAL (===) | (/==) #-}
instance Eq' (MayBe' a)
where
-- (===) (Just' x) (Just' y) = x == y
-- (/==) (Just' x) (Just' y) = x /= y
x = (Just' 2) === (Just' 3)
...provides the warning...
app\Main.hs:23:10: warning: [-Wmissing-methods]
* No explicit implementation for
either `===' or `/=='
* In the instance declaration for `Eq' (MayBe' a)'
|
23 | instance Eq' (MayBe' a)
|
...whereas this code...
instance Eq' (MayBe' a)
where
-- (===) (Just' x) (Just' y) = x == y
(/==) (Just' x) (Just' y) = x /= y
x = (Just' 2) === (Just' 3)
...leads to the following output:
False