Commit 058af6c9 authored by thomasw's avatar thomasw Committed by Austin Seipp

Refactor wild card renaming

Summary:
Refactor wild card error reporting

* Merge `HsWildcardTy` and `HsNamedWildcardTy` into one constructor
  `HsWildCardTy` with as field the new type `HsWildCardInfo`, which has two
  constructors: `AnonWildCard` and `NamedWildCard`.

* All partial type checks are removed from `RdrHsSyn.hs` and are now done
  during renaming in order to report better error messages. When wild cards
  are allowed in a type, the new function `rnLHsTypeWithWildCards` (or
  `rnHsSigTypeWithWildCards`) should be used. This will bring the named wild
  cards into scope before renaming them. When this is not done, renaming will
  trigger "Unexpected wild card..." errors.

  Unfortunately, this has to be done separately for anonymous wild cards
  because they are given a fresh name during renaming, so they will not cause
  an out-of-scope error. They are handled in `tc_hs_type`, as a special case
  of a lookup that fails.

  The previous opt-out approach is replaced with an opt-in approach. No more
  panics because of forgotten checks!

* `[t| _ |]` isn't caught by the above two checks, so it is currently handled
  by a special case. The error message (generated in the `DsM` monad) doesn't
  provide as much context information as the other cases.

* Instead of three (!) functions that walk `HsType`, there is now only one
  pure function called `collectWildCards`.

* Alternative approach: catch all unwanted wild cards in `rnHsTyKi` by looking
  at the `HsDocContext`. This will reduce the number of places to catch
  unwanted wild cards form three to one, and make the error messages more
  uniform, albeit less informative, as the error context for renaming is not
  as informative as the one for type checking. A new constructor of
  `HsDocContext` will be required for pattern synonyms signatures.

  Small problem: currently type-class type signatures can't be distinguished
  from type signatures using the `HsDocContext`.

This requires an update to the Haddock submodule.

Test Plan: validate

Reviewers: goldfire, simonpj, austin

Reviewed By: simonpj

Subscribers: bgamari, thomie, goldfire

Differential Revision: https://phabricator.haskell.org/D613

GHC Trac Issues: #10098
parent 7944a68f
......@@ -909,7 +909,12 @@ repTy (HsExplicitTupleTy _ tys) = do
repTy (HsTyLit lit) = do
lit' <- repTyLit lit
repTLit lit'
repTy (HsWildCardTy wc) = do
let name = HsSyn.wildCardName wc
putSrcSpanDs (nameSrcSpan name) $
failWithDs $ text "Unexpected wild card:" <+>
quotes (ppr name)
repTy ty = notHandled "Exotic form of type" (ppr ty)
repTyLit :: HsTyLit -> DsM (Core TH.TyLitQ)
......
......@@ -33,6 +33,9 @@ module HsTypes (
ConDeclField(..), LConDeclField, pprConDeclFields,
HsWildCardInfo(..), mkAnonWildCardTy, mkNamedWildCardTy,
wildCardName, sameWildCard, isAnonWildCard, isNamedWildCard,
mkHsQTvs, hsQTvBndrs, isHsKindedTyVar, hsTvbAllKinded,
mkExplicitHsForAllTy, mkImplicitHsForAllTy, mkQualifiedHsForAllTy,
mkHsForAllTy,
......@@ -45,7 +48,7 @@ module HsTypes (
splitHsClassTy_maybe, splitLHsClassTy_maybe,
splitHsFunType,
splitHsAppTys, hsTyGetAppHead_maybe, mkHsAppTys, mkHsOpTy,
isWildcardTy, isNamedWildcardTy,
ignoreParens,
-- Printing
pprParendHsType, pprHsForAll, pprHsForAllExtra,
......@@ -179,7 +182,7 @@ data HsWithBndrs name thing
= HsWB { hswb_cts :: thing -- Main payload (type or list of types)
, hswb_kvs :: PostRn name [Name] -- Kind vars
, hswb_tvs :: PostRn name [Name] -- Type vars
, hswb_wcs :: PostRn name [Name] -- Wildcards
, hswb_wcs :: PostRn name [Name] -- Wild cards
}
deriving (Typeable)
deriving instance (Data name, Data thing, Data (PostRn name [Name]))
......@@ -387,12 +390,7 @@ data HsType name
-- For details on above see note [Api annotations] in ApiAnnotation
| HsWildcardTy -- A type wildcard
-- ^ - 'ApiAnnotation.AnnKeywordId' : None
-- For details on above see note [Api annotations] in ApiAnnotation
| HsNamedWildcardTy name -- A named wildcard
| HsWildCardTy (HsWildCardInfo name) -- A type wildcard
-- ^ - 'ApiAnnotation.AnnKeywordId' : None
-- For details on above see note [Api annotations] in ApiAnnotation
......@@ -416,6 +414,14 @@ type HsTyOp name = (HsTyWrapper, name)
mkHsOpTy :: LHsType name -> Located name -> LHsType name -> HsType name
mkHsOpTy ty1 op ty2 = HsOpTy ty1 (WpKiApps [], op) ty2
data HsWildCardInfo name
= AnonWildCard (PostRn name Name)
-- A anonymous wild card ('_'). A name is generated during renaming.
| NamedWildCard name
-- A named wild card ('_a').
deriving (Typeable)
deriving instance (DataId name) => Data (HsWildCardInfo name)
{-
Note [HsForAllTy tyvar binders]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -568,17 +574,8 @@ mkQualifiedHsForAllTy ctxt ty = mkHsForAllTy Qualified [] ctxt ty
-- |Smart constructor for HsForAllTy, which populates the extra-constraints
-- field if a wildcard is present in the context.
mkHsForAllTy :: HsExplicitFlag -> [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName
mkHsForAllTy exp tvs (L l []) ty
= HsForAllTy exp Nothing (mkHsQTvs tvs) (L l []) ty
mkHsForAllTy exp tvs ctxt ty
= HsForAllTy exp extra (mkHsQTvs tvs) cleanCtxt ty
where -- Separate the extra-constraints wildcard when present
(cleanCtxt, extra)
| (L l HsWildcardTy) <- ignoreParens (last (unLoc ctxt)) = (init `fmap` ctxt, Just l)
| otherwise = (ctxt, Nothing)
ignoreParens (L _ (HsParTy ty)) = ty
ignoreParens ty = ty
mkHsForAllTy exp tvs ctxt ty
= HsForAllTy exp Nothing (mkHsQTvs tvs) ctxt ty
-- |When a sigtype is parsed, the type found is wrapped in an Implicit
-- HsForAllTy via mkImplicitHsForAllTy, to ensure that a signature always has a
......@@ -659,13 +656,31 @@ hsLTyVarLocNames :: LHsTyVarBndrs name -> [Located name]
hsLTyVarLocNames qtvs = map hsLTyVarLocName (hsQTvBndrs qtvs)
---------------------
isWildcardTy :: HsType a -> Bool
isWildcardTy HsWildcardTy = True
isWildcardTy _ = False
mkAnonWildCardTy :: HsType RdrName
mkAnonWildCardTy = HsWildCardTy (AnonWildCard PlaceHolder)
isNamedWildcardTy :: HsType a -> Bool
isNamedWildcardTy (HsNamedWildcardTy _) = True
isNamedWildcardTy _ = False
mkNamedWildCardTy :: n -> HsType n
mkNamedWildCardTy = HsWildCardTy . NamedWildCard
isAnonWildCard :: HsWildCardInfo name -> Bool
isAnonWildCard (AnonWildCard _) = True
isAnonWildCard _ = False
isNamedWildCard :: HsWildCardInfo name -> Bool
isNamedWildCard = not . isAnonWildCard
wildCardName :: HsWildCardInfo Name -> Name
wildCardName (NamedWildCard n) = n
wildCardName (AnonWildCard n) = n
-- Two wild cards are the same when: they're both named and have the same
-- name, or they're both anonymous and have the same location.
sameWildCard :: Eq name
=> Located (HsWildCardInfo name)
-> Located (HsWildCardInfo name) -> Bool
sameWildCard (L l1 (AnonWildCard _)) (L l2 (AnonWildCard _)) = l1 == l2
sameWildCard (L _ (NamedWildCard n1)) (L _ (NamedWildCard n2)) = n1 == n2
sameWildCard _ _ = False
splitHsAppTys :: LHsType n -> [LHsType n] -> (LHsType n, [LHsType n])
splitHsAppTys (L _ (HsAppTy f a)) as = splitHsAppTys f (a:as)
......@@ -761,6 +776,10 @@ splitHsFunType orig_ty@(L _ (HsAppTy t1 t2))
splitHsFunType other = ([], other)
ignoreParens :: LHsType name -> LHsType name
ignoreParens (L _ (HsParTy ty)) = ignoreParens ty
ignoreParens ty = ty
{-
************************************************************************
* *
......@@ -786,6 +805,10 @@ instance (OutputableBndr name) => Outputable (HsTyVarBndr name) where
instance (Outputable thing) => Outputable (HsWithBndrs name thing) where
ppr (HsWB { hswb_cts = ty }) = ppr ty
instance (Outputable name) => Outputable (HsWildCardInfo name) where
ppr (AnonWildCard _) = char '_'
ppr (NamedWildCard n) = ppr n
pprHsForAll :: OutputableBndr name => HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> SDoc
pprHsForAll exp = pprHsForAllExtra exp Nothing
......@@ -889,8 +912,8 @@ ppr_mono_ty _ (HsCoreTy ty) = ppr ty
ppr_mono_ty _ (HsExplicitListTy _ tys) = quote $ brackets (interpp'SP tys)
ppr_mono_ty _ (HsExplicitTupleTy _ tys) = quote $ parens (interpp'SP tys)
ppr_mono_ty _ (HsTyLit t) = ppr_tylit t
ppr_mono_ty _ HsWildcardTy = char '_'
ppr_mono_ty _ (HsNamedWildcardTy name) = ppr name
ppr_mono_ty _ (HsWildCardTy (AnonWildCard _)) = char '_'
ppr_mono_ty _ (HsWildCardTy (NamedWildCard name)) = ppr name
ppr_mono_ty ctxt_prec (HsWrapTy (WpKiApps _kis) ty)
= ppr_mono_ty ctxt_prec ty
......
......@@ -97,6 +97,7 @@ type DataId id =
, Data (PostRn id NameSet)
, Data (PostRn id Fixity)
, Data (PostRn id Bool)
, Data (PostRn id Name)
, Data (PostRn id [Name])
, Data (PostTc id Type)
......
......@@ -841,10 +841,9 @@ topdecl :: { OrdList (LHsDecl RdrName) }
| inst_decl { unitOL (sL1 $1 (InstD (unLoc $1))) }
| stand_alone_deriving { unitOL (sLL $1 $> (DerivD (unLoc $1))) }
| role_annot { unitOL (sL1 $1 (RoleAnnotD (unLoc $1))) }
| 'default' '(' comma_types0 ')' {% do { def <- checkValidDefaults $3
; amsu (sLL $1 $> (DefD def))
| 'default' '(' comma_types0 ')' {% amsu (sLL $1 $> (DefD (DefaultDecl $3)))
[mj AnnDefault $1
,mop $2,mcp $4] }}
,mop $2,mcp $4] }
| 'foreign' fdecl {% amsu (sLL $1 $> (snd $ unLoc $2))
(mj AnnForeign $1:(fst $ unLoc $2)) }
| '{-# DEPRECATED' deprecations '#-}' {% amsu (sLL $1 $> $ WarningD (Warnings (getDEPRECATED_PRAGs $1) (fromOL $2)))
......@@ -950,12 +949,6 @@ inst_decl :: { LInstDecl RdrName }
, cid_sigs = sigs, cid_tyfam_insts = ats
, cid_overlap_mode = $2
, cid_datafam_insts = adts }
; let err = text "In instance head:" <+> ppr $3
; checkNoPartialType err $3
; sequence_ [ checkNoPartialType err ty
| sig@(L _ (TypeSig _ ty _ )) <- sigs
, let err = text "in instance signature" <> colon
<+> quotes (ppr sig) ]
; ams (L (comb3 $1 $3 $4) (ClsInstD { cid_inst = cid }))
(mj AnnInstance $1 : (fst $ unLoc $4)) } }
......@@ -1138,7 +1131,6 @@ stand_alone_deriving :: { LDerivDecl RdrName }
{% do {
let err = text "in the stand-alone deriving instance"
<> colon <+> quotes (ppr $4)
; checkNoPartialType err $4
; ams (sLL $1 $> (DerivDecl $4 $3))
[mj AnnDeriving $1,mj AnnInstance $2] }}
......@@ -1204,7 +1196,6 @@ pattern_synonym_sig :: { LSig RdrName }
: 'pattern' con '::' ptype
{% do { let (flag, qtvs, prov, req, ty) = snd $ unLoc $4
; let sig = PatSynSig $2 (flag, mkHsQTvs qtvs) prov req ty
; checkValidPatSynSig sig
; ams (sLL $1 $> $ sig)
(mj AnnPattern $1:mj AnnDcolon $3:(fst $ unLoc $4)) } }
......@@ -1239,7 +1230,6 @@ decl_cls : at_decl_cls { sLL $1 $> (unitOL $1) }
{% do { (TypeSig l ty _) <- checkValSig $2 $4
; let err = text "in default signature" <> colon <+>
quotes (ppr ty)
; checkNoPartialType err ty
; ams (sLL $1 $> $ unitOL (sLL $1 $> $ SigD (GenericSig l ty)))
[mj AnnDefault $1,mj AnnDcolon $3] } }
......@@ -1657,10 +1647,10 @@ btype :: { LHsType RdrName }
atype :: { LHsType RdrName }
: ntgtycon { sL1 $1 (HsTyVar (unLoc $1)) } -- Not including unit tuples
| tyvar {% do { nwc <- namedWildcardsEnabled -- (See Note [Unit tuples])
| tyvar {% do { nwc <- namedWildCardsEnabled -- (See Note [Unit tuples])
; let tv@(Unqual name) = unLoc $1
; return $ if (startsWithUnderscore name && nwc)
then (sL1 $1 (HsNamedWildcardTy tv))
then (sL1 $1 (mkNamedWildCardTy tv))
else (sL1 $1 (HsTyVar tv)) } }
| strict_mark atype {% ams (sLL $1 $> (HsBangTy (snd $ unLoc $1) $2))
......@@ -1717,7 +1707,7 @@ atype :: { LHsType RdrName }
(getINTEGER $1) }
| STRING { sLL $1 $> $ HsTyLit $ HsStrTy (getSTRINGs $1)
(getSTRING $1) }
| '_' { sL1 $1 $ HsWildcardTy }
| '_' { sL1 $1 $ mkAnonWildCardTy }
-- An inst_type is what occurs in the head of an instance decl
-- e.g. (Foo a, Gaz b) => Wibble a b
......@@ -2039,14 +2029,12 @@ sigdecl :: { Located (OrdList (LHsDecl RdrName)) }
:
-- See Note [Declaration/signature overlap] for why we need infixexp here
infixexp '::' sigtypedoc
{% do ty <- checkPartialTypeSignature $3
; s <- checkValSig $1 ty
{% do s <- checkValSig $1 $3
; _ <- ams (sLL $1 $> ()) [mj AnnDcolon $2]
; return (sLL $1 $> $ unitOL (sLL $1 $> $ SigD s)) }
| var ',' sig_vars '::' sigtypedoc
{% do { ty <- checkPartialTypeSignature $5
; let sig = TypeSig ($1 : reverse (unLoc $3)) ty PlaceHolder
{% do { let sig = TypeSig ($1 : reverse (unLoc $3)) $5 PlaceHolder
; addAnnotation (gl $1) AnnComma (gl $2)
; ams (sLL $1 $> $ toOL [ sLL $1 $> $ SigD sig ])
[mj AnnDcolon $4] } }
......@@ -2318,10 +2306,7 @@ aexp2 :: { LHsExpr RdrName }
| TH_TY_QUOTE gtycon {% ams (sLL $1 $> $ HsBracket (VarBr False (unLoc $2))) [mj AnnThTyQuote $1,mj AnnName $2] }
| '[|' exp '|]' {% ams (sLL $1 $> $ HsBracket (ExpBr $2)) [mo $1,mc $3] }
| '[||' exp '||]' {% ams (sLL $1 $> $ HsBracket (TExpBr $2)) [mo $1,mc $3]}
| '[t|' ctype '|]' {% checkNoPartialType
(text "in type brackets" <> colon
<+> quotes (text "[t|" <+> ppr $2 <+> text "|]")) $2 >>
ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mc $3] }
| '[t|' ctype '|]' {% ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mc $3] }
| '[p|' infixexp '|]' {% checkPattern empty $2 >>= \p ->
ams (sLL $1 $> $ HsBracket (PatBr p))
[mo $1,mc $3] }
......@@ -3301,8 +3286,8 @@ hintExplicitForall span = do
, text "extension to enable explicit-forall syntax: \x2200 <tvs>. <type>"
]
namedWildcardsEnabled :: P Bool
namedWildcardsEnabled = liftM ((Opt_NamedWildCards `xopt`) . dflags) getPState
namedWildCardsEnabled :: P Bool
namedWildCardsEnabled = liftM ((Opt_NamedWildCards `xopt`) . dflags) getPState
{-
%************************************************************************
......
This diff is collapsed.
......@@ -813,11 +813,17 @@ renameSig _ (IdSig x)
renameSig ctxt sig@(TypeSig vs ty _)
= do { new_vs <- mapM (lookupSigOccRn ctxt sig) vs
-- (named and anonymous) wildcards are bound here.
; (wcs, ty') <- extractWildcards ty
; bindLocatedLocalsFV wcs $ \wcs_new -> do {
(new_ty, fvs) <- rnHsSigType (ppr_sig_bndrs vs) ty'
; return (TypeSig new_vs new_ty wcs_new, fvs) } }
; let doc = ppr_sig_bndrs vs
wildCardsAllowed = case ctxt of
TopSigCtxt _ -> True
LocalBindCtxt _ -> True
_ -> False
; (new_ty, fvs, wcs)
<- if wildCardsAllowed
then rnHsSigTypeWithWildCards doc ty
else do { (new_ty, fvs) <- rnHsSigType doc ty
; return (new_ty, fvs, []) }
; return (TypeSig new_vs new_ty wcs, fvs) }
renameSig ctxt sig@(GenericSig vs ty)
= do { defaultSigs_on <- xoptM Opt_DefaultSignatures
......
......@@ -247,12 +247,10 @@ rnExpr (RecordUpd expr rbinds _ _ _)
fvExpr `plusFV` fvRbinds) }
rnExpr (ExprWithTySig expr pty PlaceHolder)
= do { (wcs, pty') <- extractWildcards pty
; bindLocatedLocalsFV wcs $ \wcs_new -> do {
(pty'', fvTy) <- rnLHsType ExprWithTySigCtx pty'
; (expr', fvExpr) <- bindSigTyVarsFV (hsExplicitTvs pty'') $
rnLExpr expr
; return (ExprWithTySig expr' pty'' wcs_new, fvExpr `plusFV` fvTy) } }
= do { (pty', fvTy, wcs) <- rnLHsTypeWithWildCards ExprWithTySigCtx pty
; (expr', fvExpr) <- bindSigTyVarsFV (hsExplicitTvs pty') $
rnLExpr expr
; return (ExprWithTySig expr' pty' wcs, fvExpr `plusFV` fvTy) }
rnExpr (HsIf _ p b1 b2)
= do { (p', fvP) <- rnLExpr p
......
This diff is collapsed.
......@@ -827,9 +827,16 @@ pprBinders bndrs = pprWithCommas ppr bndrs
notFound :: Name -> TcM TyThing
notFound name
= do { lcl_env <- getLclEnv
; namedWildCardsEnabled <- xoptM Opt_NamedWildCards
; let stage = tcl_th_ctxt lcl_env
isWildCard = case getOccString name of
('_':_:_) | namedWildCardsEnabled -> True
"_" -> True
_ -> False
; case stage of -- See Note [Out of scope might be a staging error]
Splice {} -> stageRestrictionError (quotes (ppr name))
_ | isWildCard -> failWithTc $
text "Unexpected wild card:" <+> quotes (ppr name)
_ -> failWithTc $
vcat[ptext (sLit "GHC internal error:") <+> quotes (ppr name) <+>
ptext (sLit "is not in scope during type checking, but it passed the renamer"),
......
......@@ -536,12 +536,9 @@ tc_hs_type hs_ty@(HsTyLit (HsStrTy _ s)) exp_kind
; checkWiredInTyCon typeSymbolKindCon
; return (mkStrLitTy s) }
tc_hs_type HsWildcardTy _ = panic "tc_hs_type HsWildcardTy"
-- unnamed wildcards should have been replaced by named wildcards
tc_hs_type hs_ty@(HsNamedWildcardTy name) exp_kind
= do { (ty, k) <- tcTyVar name
tc_hs_type hs_ty@(HsWildCardTy wc) exp_kind
= do { let name = wildCardName wc
; (ty, k) <- tcTyVar name
; checkExpectedKind hs_ty k exp_kind
; return ty }
......
......@@ -1845,11 +1845,8 @@ tcRnType :: HscEnv
tcRnType hsc_env normalise rdr_type
= runTcInteractive hsc_env $
setXOptM Opt_PolyKinds $ -- See Note [Kind-generalise in tcRnType]
do { (wcs, rdr_type') <- extractWildcards rdr_type
; (rn_type, wcs) <- bindLocatedLocalsRn wcs $ \wcs_new -> do {
; (rn_type, _fvs) <- rnLHsType GHCiCtx rdr_type'
do { (rn_type, _fvs, wcs) <- rnLHsTypeWithWildCards GHCiCtx rdr_type
; failIfErrsM
; return (rn_type, wcs_new) }
-- Now kind-check the type
-- It can have any rank or kind
......
......@@ -691,6 +691,9 @@ addErr msg = do { loc <- getSrcSpanM; addErrAt loc msg }
failWith :: MsgDoc -> TcRn a
failWith msg = addErr msg >> failM
failAt :: SrcSpan -> MsgDoc -> TcRn a
failAt loc msg = addErrAt loc msg >> failM
addErrAt :: SrcSpan -> MsgDoc -> TcRn ()
-- addErrAt is mainly (exclusively?) used by the renamer, where
-- tidying is not an issue, but it's all lazy so the extra
......
ExtraConstraintsWildcardNotLast.hs:4:9:
Invalid partial type signature:
(_, Eq a) => a -> a
An extra-constraints wildcard is only allowed
Invalid partial type: (_, Eq a) => a -> a
An extra-constraints wild card must occur
at the end of the constraints
In the type signature for ‘foo’
{-# LANGUAGE PartialTypeSignatures #-}
module ExtraConstraintsWildcardTwice where
foo :: ((_), _) => a -> a
foo = undefined
ExtraConstraintsWildcardTwice.hs:4:10:
Invalid partial type: (_, _) => a -> a
Only a single extra-constraints wild card is allowed
In the type signature for ‘foo’
NamedExtraConstraintsWildcard.hs:4:15:
Invalid partial type signature:
(Eq a, _a) => a -> a
A named wildcard cannot occur as a constraint
Invalid partial type: (Eq a, _a) => a -> a
An extra-constraints wild card cannot be named
In the type signature for ‘foo’
NamedWildcardsNotInMonotype.hs:4:21:
Invalid partial type signature:
(Show _a, Eq _c, Eq _b) => _a -> _b -> String
The named wildcard ‘_c’ is only allowed in the constraints
when it also occurs in the (mono)type
Invalid partial type: (Show _a, Eq _c, Eq _b) => _a -> _b -> String
The named wild card ‘_c’ is only allowed in the constraints
when it also occurs in the rest of the type
In the type signature for ‘foo’
NestedExtraConstraintsWildcard.hs:4:23:
Invalid partial type signature:
Bool -> (Eq a, _) => a
An extra-constraints wildcard is only allowed
at the top-level of the signature
Invalid partial type: Bool -> (Eq a, _) => a
An extra-constraints wild card is only allowed
in the top-level context
In the type signature for ‘foo’
NestedNamedExtraConstraintsWildcard.hs:4:23:
Invalid partial type signature:
Bool -> (Eq a, _a) => a
A named wildcard cannot occur as a constraint
Invalid partial type: Bool -> (Eq a, _a) => a
An extra-constraints wild card cannot be named
In the type signature for ‘foo’
......@@ -3,4 +3,4 @@ module PartialClassMethodSignature where
class Foo a where
foo :: (Eq a, _) => a -> _
foo :: a -> _
PartialClassMethodSignature.hs:6:17:
The type signature of a class method cannot be partial:
foo :: (Eq a, _) => a -> _
PartialClassMethodSignature.hs:6:15:
Unexpected wild card: ‘_’
In the type ‘a -> _’
In the class declaration for ‘Foo’
{-# LANGUAGE PartialTypeSignatures #-}
module PartialClassMethodSignature2 where
class Foo a where
foo :: (Eq a, _) => a -> a
PartialClassMethodSignature2.hs:5:17:
Unexpected wild card: ‘_’
In the type ‘(Eq a, _) => a -> a’
In the class declaration for ‘Foo’
UnnamedConstraintWildcard1.hs:4:13:
Invalid partial type signature:
Show _ => a -> String
Wildcards are not allowed within the constraints
Invalid partial type: Show _ => a -> String
Anonymous wild cards are not allowed in constraints
In the type signature for ‘foo’
UnnamedConstraintWildcard2.hs:4:8:
Invalid partial type signature:
_ a => a -> String
Wildcards are not allowed within the constraints
Invalid partial type: _ a => a -> String
Anonymous wild cards are not allowed in constraints
In the type signature for ‘foo’
WildcardInADT1.hs:4:26:
A constructor cannot have a partial type:
Foo (Either _ a)
Unexpected wild card: ‘_’
In the type ‘Either _ a’
In the definition of data constructor ‘Foo’
In the data declaration for ‘Foo’
WildcardInADT2.hs:4:34:
A constructor cannot have a partial type:
Foo {get :: Either _ a}
Unexpected wild card: ‘_’
In the type ‘Either _ a’
In the definition of data constructor ‘Foo’
In the data declaration for ‘Foo’
WildcardInADT3.hs:4:27:
A constructor cannot have a partial type:
Foo {get :: _ => a}
Unexpected wild card: ‘_’
In the type ‘_ => a’
In the definition of data constructor ‘Foo’
In the data declaration for ‘Foo’
......@@ -3,5 +3,5 @@ WildcardInADTContext1.hs:1:37: Warning:
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
WildcardInADTContext1.hs:4:13:
Wildcard not allowed
In the context: (Eq a, _)
Unexpected wild card: ‘_’
In the data declaration for ‘Foo’
......@@ -3,5 +3,5 @@ WildcardInADTContext2.hs:1:53: Warning:
-XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
WildcardInADTContext2.hs:4:10:
Wildcard not allowed
In the context: (Eq _a)
Unexpected wild card: ‘_a’
In the data type declaration for ‘Foo’
WildcardInDefault.hs:4:10:
Wildcard not allowed
In declaration: default (_)
Unexpected wild card: ‘_’
In a type in a `default' declaration: _
When checking the types in a default declaration
{-# LANGUAGE DefaultSignatures #-}
module WildcardInDefaultSignature where
class C a where default f :: _
class C a where
f :: a
default f :: _
WildcardInDefaultSignature.hs:4:30:
Wildcard not allowed
in default signature: ‘_’
WildcardInDefaultSignature.hs:7:16:
Unexpected wild card: ‘_’
In the type ‘_’
In the class declaration for ‘C’
WildcardInDeriving.hs:5:22:
Wildcard not allowed
In the deriving items: (_)
Unexpected wild card: ‘_’
In the data declaration for ‘Foo’
WildcardInForeignExport.hs:6:37:
Wildcard not allowed
In foreign export declaration ‘foo’
CInt -> _
Unexpected wild card: ‘_’
In the foreign declaration for ‘foo’: foo :: CInt -> _
When checking declaration:
foreign export ccall "foo" foo :: CInt -> _
WildcardInForeignImport.hs:6:48:
Wildcard not allowed
In foreign import declaration ‘c_sin’
CDouble -> _
Unexpected wild card: ‘_’
In the foreign declaration for ‘c_sin’: c_sin :: CDouble -> _
When checking declaration:
foreign import ccall safe "static sin" c_sin :: CDouble -> _
WildcardInGADT1.hs:5:19:
A constructor cannot have a partial type:
Foo :: Either a _ -> Foo a
Unexpected wild card: ‘_’
In the type ‘Either a _’
In the definition of data constructor ‘Foo’
In the data declaration for ‘Foo’
WildcardInGADT2.hs:5:17:
A constructor cannot have a partial type:
(Eq a, _) => Maybe a -> Foo a
Unexpected wild card: ‘_’
In the definition of data constructor ‘Foo’
In the data declaration for ‘Foo’
WildcardInInstanceHead.hs:7:14:
Wildcard not allowed
In instance head: Foo _
Unexpected wild card: ‘_’
In the instance declaration for ‘Foo _’
WildcardInInstanceSig.hs:4:35:
Wildcard not allowed
in instance signature: ‘negate :: _’
Unexpected wild card: ‘_’
In the type signature for ‘negate’: negate :: _
In the instance declaration for ‘Num Bool’
WildcardInNewtype.hs:7:29:
A constructor cannot have a partial type:
Foo (Either _ a)
Unexpected wild card: ‘_’
In the type ‘Either _ a’
In the definition of data constructor ‘Foo’
In the newtype declaration for ‘Foo’
WildcardInPatSynSig.hs:4:37:
Wildcard not allowed
In pattern synonym type signature:
pattern Single :: () => (Show a) => _ -> [a]
Unexpected wild card: ‘_’
In the type signature for ‘Single’: Single :: _ -> [a]
WildcardInStandaloneDeriving.hs:4:19:
Wildcard not allowed
in the stand-alone deriving instance: ‘_’
WildcardInStandaloneDeriving.hs:4:19: Malformed instance: _
WildcardInTypeBrackets.hs:4:11:
Wildcard not allowed
in type brackets: ‘[t| _ |]’
WildcardInTypeBrackets.hs:4:11: Unexpected wild card: ‘_’
WildcardInTypeFamilyInstanceLHS.hs:8:13:
Wildcard not allowed
In type family instance equation of ‘Dual’: Dual _
Unexpected wild card: ‘_’
In the type ‘_’
In the type instance declaration for ‘Dual’
In the instance declaration for ‘Foo Int’