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
Shayne Fletcher
Glasgow Haskell Compiler
Commits
9c54185b
Commit
9c54185b
authored
Jul 20, 2016
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments + tiny refactor of isNullarySrcDataCon
parent
a09c0e3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
compiler/basicTypes/DataCon.hs
compiler/basicTypes/DataCon.hs
+14
-4
No files found.
compiler/basicTypes/DataCon.hs
View file @
9c54185b
...
...
@@ -382,10 +382,10 @@ data DataCon
-- Constructor representation
dcRep
::
DataConRep
,
-- Cached
-- dcRepArity == length dataConRepArgTys
-- Cached; see Note [DataCon arities]
-- INVARIANT: dcRepArity == length dataConRepArgTys
-- INVARIANT: dcSourceArity == length dcOrigArgTys
dcRepArity
::
Arity
,
-- dcSourceArity == length dcOrigArgTys
dcSourceArity
::
Arity
,
-- Result type of constructor is T t1..tn
...
...
@@ -427,6 +427,14 @@ Why do we need the TyVarBinders, rather than just the TyVars? So that
we can construct the right type for the DataCon with its foralls
attributed the correce visiblity. That in turn governs whether you
can use visible type application at a call of the data constructor.
Note [DataCon arities]
~~~~~~~~~~~~~~~~~~~~~~
dcSourceArity does not take constraints into account,
but dcRepArity does. For example:
MkT :: Ord a => a -> T a
dcSourceArity = 1
dcRepArity = 2
-}
data
DataConRep
...
...
@@ -979,10 +987,12 @@ dataConRepArity :: DataCon -> Arity
dataConRepArity
(
MkData
{
dcRepArity
=
arity
})
=
arity
-- | Return whether there are any argument types for this 'DataCon's original source type
-- See Note [DataCon arities]
isNullarySrcDataCon
::
DataCon
->
Bool
isNullarySrcDataCon
dc
=
null
(
dcOrigArgTys
dc
)
isNullarySrcDataCon
dc
=
dataConSourceArity
dc
==
0
-- | Return whether there are any argument types for this 'DataCon's runtime representation type
-- See Note [DataCon arities]
isNullaryRepDataCon
::
DataCon
->
Bool
isNullaryRepDataCon
dc
=
dataConRepArity
dc
==
0
...
...
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