diff options
author | Twan van Laarhoven <twanvl@gmail.com> | 2013-09-11 15:32:33 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2013-09-18 09:53:18 +0200 |
commit | bd42c9dfd1c9ce19672e1d63871a237c268e0212 (patch) | |
tree | 0d9e6e3fdedae39176751cc62c1458344a0cf781 /compiler/parser/Parser.y.pp | |
parent | b6bc3263d0099e79b437ac5f3c053452c608c710 (diff) | |
download | haskell-bd42c9dfd1c9ce19672e1d63871a237c268e0212.tar.gz |
Implement checkable "minimal complete definitions" (#7633)
This commit adds a `{-# MINIMAL #-}` pragma, which defines the possible
minimal complete definitions for a class. The body of the pragma is a
boolean formula of names.
The old warning for missing methods is replaced with this new one.
Note: The interface file format is changed to store the minimal complete
definition.
Authored-by: Twan van Laarhoven <twanvl@gmail.com>
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Diffstat (limited to 'compiler/parser/Parser.y.pp')
-rw-r--r-- | compiler/parser/Parser.y.pp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 0ea48dd557..2b734cad41 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -41,6 +41,7 @@ import BasicTypes import DynFlags import OrdList import HaddockUtils +import BooleanFormula ( BooleanFormula, mkAnd, mkOr, mkTrue, mkVar ) import FastString import Maybes ( orElse ) @@ -266,6 +267,7 @@ incorrect. '{-# VECTORISE' { L _ ITvect_prag } '{-# VECTORISE_SCALAR' { L _ ITvect_scalar_prag } '{-# NOVECTORISE' { L _ ITnovect_prag } + '{-# MINIMAL' { L _ ITminimal_prag } '{-# CTYPE' { L _ ITctype } '#-}' { L _ ITclose_prag } @@ -1409,6 +1411,9 @@ sigdecl :: { Located (OrdList (LHsDecl RdrName)) } | t <- $5] } | '{-# SPECIALISE' 'instance' inst_type '#-}' { LL $ unitOL (LL $ SigD (SpecInstSig $3)) } + -- A minimal complete definition + | '{-# MINIMAL' name_boolformula_opt '#-}' + { LL $ unitOL (LL $ SigD (MinimalSig $2)) } activation :: { Maybe Activation } : {- empty -} { Nothing } @@ -1849,6 +1854,22 @@ ipvar :: { Located HsIPName } ----------------------------------------------------------------------------- -- Warnings and deprecations +name_boolformula_opt :: { BooleanFormula (Located RdrName) } + : name_boolformula { $1 } + | {- empty -} { mkTrue } + +name_boolformula :: { BooleanFormula (Located RdrName) } + : name_boolformula_and { $1 } + | name_boolformula_and '|' name_boolformula { mkOr [$1,$3] } + +name_boolformula_and :: { BooleanFormula (Located RdrName) } + : name_boolformula_atom { $1 } + | name_boolformula_atom ',' name_boolformula_and { mkAnd [$1,$3] } + +name_boolformula_atom :: { BooleanFormula (Located RdrName) } + : '(' name_boolformula ')' { $2 } + | name_var { mkVar $1 } + namelist :: { Located [RdrName] } namelist : name_var { L1 [unLoc $1] } | name_var ',' namelist { LL (unLoc $1 : unLoc $3) } |