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
Reinier Maas
GHC
Commits
7cf9432a
Commit
7cf9432a
authored
12 years ago
by
Simon Peyton Jones
Browse files
Options
Downloads
Patches
Plain Diff
Test Trac #5821
parent
94187d0c
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
testsuite/tests/rebindable/T5821.hs
+71
-0
71 additions, 0 deletions
testsuite/tests/rebindable/T5821.hs
testsuite/tests/rebindable/all.T
+2
-0
2 additions, 0 deletions
testsuite/tests/rebindable/all.T
with
73 additions
and
0 deletions
testsuite/tests/rebindable/T5821.hs
0 → 100644
+
71
−
0
View file @
7cf9432a
{-# LANGUAGE
ExplicitForAll
, GADTs
, RebindableSyntax #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
module
T5821a
(
Writer
,
runWriter
,
execWriter
,
WriterT
,
runWriterT
,
execWriterT
,
tell
)
where
import
Control.Category
(
Category
(
id
),
(
>>>
))
import
Prelude
hiding
(
Monad
(
..
),
id
)
import
qualified
Prelude
newtype
Identity
a
=
Identity
{
runIdentity
::
a
}
class
Monad
m
where
(
>>=
)
::
forall
e
ex
x
a
b
.
m
e
ex
a
->
(
a
->
m
ex
x
b
)
->
m
e
x
b
(
>>
)
::
forall
e
ex
x
a
b
.
m
e
ex
a
->
m
ex
x
b
->
m
e
x
b
return
::
a
->
m
ex
ex
a
fail
::
String
->
m
e
x
a
{-# INLINE (>>) #-}
m
>>
k
=
m
>>=
\
_
->
k
fail
=
error
type
Writer
w
=
WriterT
w
Identity
runWriter
::
Writer
w
e
x
a
->
(
a
,
w
e
x
)
runWriter
=
runIdentity
.
runWriterT
execWriter
::
Writer
w
e
x
a
->
w
e
x
execWriter
m
=
snd
(
runWriter
m
)
newtype
WriterT
w
m
e
x
a
=
WriterT
{
runWriterT
::
m
(
a
,
w
e
x
)
}
execWriterT
::
Prelude
.
Monad
m
=>
WriterT
w
m
e
x
a
->
m
(
w
e
x
)
execWriterT
m
=
do
~
(
_
,
w
)
<-
runWriterT
m
return
w
where
(
>>=
)
=
(
Prelude
.>>=
)
return
=
Prelude
.
return
instance
(
Category
w
,
Prelude
.
Monad
m
)
=>
Monad
(
WriterT
w
m
)
where
return
a
=
WriterT
$
return
(
a
,
id
)
where
return
=
Prelude
.
return
m
>>=
k
=
WriterT
$
do
~
(
a
,
w
)
<-
runWriterT
m
~
(
b
,
w'
)
<-
runWriterT
(
k
a
)
return
(
b
,
w
>>>
w'
)
where
(
>>=
)
=
(
Prelude
.>>=
)
return
=
Prelude
.
return
fail
msg
=
WriterT
$
fail
msg
where
fail
=
Prelude
.
fail
tell
::
(
Category
w
,
Prelude
.
Monad
m
)
=>
w
e
x
->
WriterT
w
m
e
x
()
tell
w
=
WriterT
$
return
(
()
,
w
)
where
return
=
Prelude
.
return
This diff is collapsed.
Click to expand it.
testsuite/tests/rebindable/all.T
+
2
−
0
View file @
7cf9432a
...
...
@@ -29,3 +29,5 @@ test('DoRestrictedM', normal, compile, [''])
test
('
DoParamM
',
reqlib
('
mtl
'),
compile_fail
,
[''])
test
('
T5038
',
normal
,
compile_and_run
,
[''])
test
('
T4851
',
normal
,
compile
,
[''])
test
('
T5821
',
normal
,
compile
,
[''])
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