Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Alex D
GHC
Commits
13adf25f
Commit
13adf25f
authored
Sep 14, 2010
by
simonpj@microsoft.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comment on what an "enumeration" type is
parent
afe45347
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
compiler/iface/BuildTyCl.lhs
compiler/iface/BuildTyCl.lhs
+2
-8
compiler/types/TyCon.lhs
compiler/types/TyCon.lhs
+12
-1
No files found.
compiler/iface/BuildTyCl.lhs
View file @
13adf25f
...
...
@@ -112,15 +112,9 @@ mkDataTyConRhs :: [DataCon] -> AlgTyConRhs
mkDataTyConRhs cons
= DataTyCon {
data_cons = cons,
is_enum = -- We define datatypes with no constructors to not be
-- enumerations; this fixes trac #2578, Otherwise we
-- end up generating an empty table for
-- <mod>_<type>_closure_tbl
-- which is used by tagToEnum# to map Int# to constructors
-- in an enumeration. The empty table apparently upset
-- the linker.
not (null cons) &&
is_enum = not (null cons) &&
all isNullarySrcDataCon cons
-- See Note [Enumeration types] in TyCon
}
mkNewTyConRhs :: Name -> TyCon -> DataCon -> TcRnIf m n AlgTyConRhs
...
...
compiler/types/TyCon.lhs
View file @
13adf25f
...
...
@@ -440,7 +440,7 @@ data AlgTyConRhs
-- (see the tag assignment in DataCon.mkDataCon)
is_enum :: Bool -- ^ Cached value: is this an enumeration type?
--
(
See
'is
Enumeration
TyCon')
-- See
Note [
Enumeration
types]
}
-- | Information about those 'TyCon's derived from a @newtype@ declaration
...
...
@@ -580,6 +580,16 @@ data CoTyConDesc
| CoUnsafe
\end{code}
Note [Enumeration types]
~~~~~~~~~~~~~~~~~~~~~~~~
We define datatypes with no constructors to not be
enumerations; this fixes trac #2578, Otherwise we
end up generating an empty table for
<mod>_<type>_closure_tbl
which is used by tagToEnum# to map Int# to constructors
in an enumeration. The empty table apparently upset
the linker.
Note [Newtype coercions]
~~~~~~~~~~~~~~~~~~~~~~~~
The NewTyCon field nt_co is a a TyCon (a coercion constructor in fact)
...
...
@@ -983,6 +993,7 @@ isGadtSyntaxTyCon _ = False
-- | Is this an algebraic 'TyCon' which is just an enumeration of values?
isEnumerationTyCon :: TyCon -> Bool
-- See Note [Enumeration types] in TyCon
isEnumerationTyCon (AlgTyCon {algTcRhs = DataTyCon { is_enum = res }}) = res
isEnumerationTyCon (TupleTyCon {tyConArity = arity}) = arity == 0
isEnumerationTyCon _ = False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment