Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
8e1115a7
Commit
8e1115a7
authored
27 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1997-08-03 02:19:46 by sof]
Improved error messages for derivings of types with wrong shape
parent
cfad1978
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/typecheck/TcDeriv.lhs
+18
-13
18 additions, 13 deletions
ghc/compiler/typecheck/TcDeriv.lhs
with
18 additions
and
13 deletions
ghc/compiler/typecheck/TcDeriv.lhs
+
18
−
13
View file @
8e1115a7
...
...
@@ -48,8 +48,8 @@ import Name ( isLocallyDefined, getSrcLoc, ExportFlag(..), Provenance,
)
import Outputable ( PprStyle(..), Outputable(..){-instances e.g., (,)-} )
import PprType ( GenType, GenTyVar, GenClass, TyCon )
import Pretty ( ($$), vcat, hsep, hcat,
ptext,
text,
char, hang, Doc )
import Pretty ( ($$), vcat, hsep, hcat,
parens,
ptext, char, hang, Doc )
import SrcLoc ( mkGeneratedSrcLoc, SrcLoc )
import TyCon ( tyConTyVars, tyConDataCons, tyConDerivings,
tyConTheta, maybeTyConSingleCon, isDataTyCon,
...
...
@@ -236,7 +236,7 @@ tcDeriving modname rn_name_supply inst_decl_infos_in
-- method bindings for the instances.
(dfun_names_w_method_binds, rn_extra_binds)
= renameSourceCode modname rn_name_supply (
bindLocatedLocalsRn (\_ -> text "deriving") mbinders $ \ _ ->
bindLocatedLocalsRn (\_ ->
p
text
(SLIT(
"deriving")
))
mbinders $ \ _ ->
rnTopMonoBinds extra_mbinds [] `thenRn` \ rn_extra_binds ->
mapRn rn_one method_binds_s `thenRn` \ dfun_names_w_method_binds ->
returnRn (dfun_names_w_method_binds, rn_extra_binds)
...
...
@@ -339,20 +339,24 @@ makeDerivEqns
is_enumeration = isEnumerationTyCon tycon
is_single_con = maybeToBool (maybeTyConSingleCon tycon)
chk_clas clas_uniq clas_str cond
single_nullary_why = SLIT("one constructor data type or type with all nullary constructors expected")
nullary_why = SLIT("data type with all nullary constructors expected")
chk_clas clas_uniq clas_str clas_why cond
= if (clas_uniq == clas_key)
then checkTc cond (derivingThingErr clas_str tycon)
then checkTc cond (derivingThingErr clas_str
clas_why
tycon)
else returnTc ()
in
-- Are things OK for deriving Enum (if appropriate)?
chk_clas enumClassKey
"Enum"
is_enumeration `thenTc_`
chk_clas enumClassKey
(SLIT("Enum")) nullary_why
is_enumeration `thenTc_`
-- Are things OK for deriving Bounded (if appropriate)?
chk_clas boundedClassKey "Bounded"
(is_enumeration || is_single_con) `thenTc_`
chk_clas boundedClassKey
(SLIT(
"Bounded"
)) single_nullary_why
(is_enumeration || is_single_con) `thenTc_`
-- Are things OK for deriving Ix (if appropriate)?
chk_clas ixClassKey "Ix.Ix" (is_enumeration || is_single_con)
chk_clas ixClassKey (SLIT("Ix.Ix")) single_nullary_why
(is_enumeration || is_single_con)
------------------------------------------------------------------
cmp_deriv :: (Class, TyCon) -> (Class, TyCon) -> TAG_
...
...
@@ -712,9 +716,10 @@ gen_taggery_Names inst_infos
\end{code}
\begin{code}
derivingThingErr ::
String
-> TyCon -> Error
derivingThingErr ::
FAST_STRING -> FAST_STRING
-> TyCon -> Error
derivingThingErr thing tycon sty
= hang (hsep [ptext SLIT("Can't make a derived instance of"), text thing])
4 (hsep [ptext SLIT("for the type"), ppr sty tycon])
derivingThingErr thing why tycon sty
= hang (hsep [ptext SLIT("Can't make a derived instance of"), ptext thing])
0 (hang (hsep [ptext SLIT("for the type"), ppr sty tycon])
0 (parens (ptext why)))
\end{code}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment