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
LinuxUser GD
GHC
Commits
53263480
Commit
53263480
authored
10 years ago
by
Gergő Érdi
Browse files
Options
Downloads
Patches
Plain Diff
Use a new $b prefix for pattern synonym builder names, instead of re-using $W from wrappers
parent
397048af
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compiler/basicTypes/OccName.hs
+7
-2
7 additions, 2 deletions
compiler/basicTypes/OccName.hs
compiler/basicTypes/PatSyn.hs
+6
-6
6 additions, 6 deletions
compiler/basicTypes/PatSyn.hs
compiler/typecheck/TcPatSyn.hs
+1
-1
1 addition, 1 deletion
compiler/typecheck/TcPatSyn.hs
with
14 additions
and
9 deletions
compiler/basicTypes/OccName.hs
+
7
−
2
View file @
53263480
...
...
@@ -53,7 +53,9 @@ module OccName (
-- ** Derived 'OccName's
isDerivedOccName
,
mkDataConWrapperOcc
,
mkWorkerOcc
,
mkMatcherOcc
,
mkDefaultMethodOcc
,
mkDataConWrapperOcc
,
mkWorkerOcc
,
mkMatcherOcc
,
mkBuilderOcc
,
mkDefaultMethodOcc
,
mkGenDefMethodOcc
,
mkDerivedTyConOcc
,
mkNewTyCoOcc
,
mkClassOpAuxOcc
,
mkCon2TagOcc
,
mkTag2ConOcc
,
mkMaxTagOcc
,
...
...
@@ -595,7 +597,9 @@ isDerivedOccName occ =
':'
:
c
:
_
|
isAlphaNum
c
->
True
_other
->
False
mkDataConWrapperOcc
,
mkWorkerOcc
,
mkMatcherOcc
,
mkDefaultMethodOcc
,
mkDataConWrapperOcc
,
mkWorkerOcc
,
mkMatcherOcc
,
mkBuilderOcc
,
mkDefaultMethodOcc
,
mkGenDefMethodOcc
,
mkDerivedTyConOcc
,
mkClassDataConOcc
,
mkDictOcc
,
mkIPOcc
,
mkSpecOcc
,
mkForeignExportOcc
,
mkRepEqOcc
,
mkGenOcc1
,
mkGenOcc2
,
mkGenD
,
mkGenR
,
mkGen1R
,
mkGenRCo
,
...
...
@@ -608,6 +612,7 @@ mkDataConWrapperOcc, mkWorkerOcc, mkMatcherOcc, mkDefaultMethodOcc,
mkDataConWrapperOcc
=
mk_simple_deriv
varName
"$W"
mkWorkerOcc
=
mk_simple_deriv
varName
"$w"
mkMatcherOcc
=
mk_simple_deriv
varName
"$m"
mkBuilderOcc
=
mk_simple_deriv
varName
"$b"
mkDefaultMethodOcc
=
mk_simple_deriv
varName
"$dm"
mkGenDefMethodOcc
=
mk_simple_deriv
varName
"$gdm"
mkClassOpAuxOcc
=
mk_simple_deriv
varName
"$c"
...
...
This diff is collapsed.
Click to expand it.
compiler/basicTypes/PatSyn.hs
+
6
−
6
View file @
53263480
...
...
@@ -83,7 +83,7 @@ data PatSyn
psBuilder
::
Maybe
(
Id
,
Bool
)
-- Nothing => uni-directional pattern synonym
-- Just (builder, is_unlifted) => bi-directional
--
Wrapp
er function, of type
--
Build
er function, of type
-- forall univ_tvs, ex_tvs. (prov_theta, req_theta)
-- => arg_tys -> res_ty
-- See Note [Builder for pattern synonyms with unboxed type]
...
...
@@ -161,12 +161,12 @@ For *bidirectional* pattern synonyms, we also generate a "builder"
function which implements the pattern synonym in an expression
context. For our running example, it will be:
$
W
P :: forall t b. (Show (Maybe t), Ord b, Eq t, Num t)
$
b
P :: forall t b. (Show (Maybe t), Ord b, Eq t, Num t)
=> b -> T (Maybe t)
$
W
P x = MkT [x] (Just 42)
$
b
P x = MkT [x] (Just 42)
NB: the existential/universal and required/provided split does not
apply to the
wrapp
er since you are only putting stuff in, not getting
apply to the
build
er since you are only putting stuff in, not getting
stuff out.
Injectivity of bidirectional pattern synonyms is checked in
...
...
@@ -181,8 +181,8 @@ would be a top-level declaration with an unboxed type.
pattern P = 0#
$
W
P :: Void# -> Int#
$
W
P _ = 0#
$
b
P :: Void# -> Int#
$
b
P _ = 0#
This means that when typechecking an occurrence of P in an expression,
we must remember that the builder has this void argument. This is
...
...
This diff is collapsed.
Click to expand it.
compiler/typecheck/TcPatSyn.hs
+
1
−
1
View file @
53263480
...
...
@@ -326,7 +326,7 @@ mkPatSynBuilderId dir (L _ name) qtvs theta arg_tys pat_ty
|
isUnidirectional
dir
=
return
Nothing
|
otherwise
=
do
{
builder_name
<-
newImplicitBinder
name
mk
DataConWork
erOcc
=
do
{
builder_name
<-
newImplicitBinder
name
mk
Build
erOcc
;
let
builder_sigma
=
mkSigmaTy
qtvs
theta
(
mkFunTys
builder_arg_tys
pat_ty
)
builder_id
=
mkExportedLocalId
VanillaId
builder_name
builder_sigma
-- See Note [Exported LocalIds] in Id
...
...
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