Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,323
Issues
4,323
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
363
Merge Requests
363
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
d4a926ba
Commit
d4a926ba
authored
Apr 29, 2015
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Trac #10226
Fixed by the patch for #10009
parent
a1275a76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
testsuite/tests/indexed-types/should_compile/T10226.hs
testsuite/tests/indexed-types/should_compile/T10226.hs
+59
-0
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/indexed-types/should_compile/all.T
+1
-1
No files found.
testsuite/tests/indexed-types/should_compile/T10226.hs
0 → 100644
View file @
d4a926ba
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
-- only necessary in 7.10
{-# LANGUAGE FlexibleContexts #-}
-- necessary for showFromF' example
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
module
T10226
where
type
family
F
a
type
family
FInv
a
-- This definition is accepted in 7.8 without anything extra, but requires
-- AllowAmbiguousTypes in 7.10 (this, by itself, is not a problem):
showFromF
::
(
Show
a
,
FInv
(
F
a
)
~
a
)
=>
F
a
->
String
showFromF
fa
=
undefined
-- Consider what happens when we attempt to call `showFromF` at some type b.
-- In order to check that this is valid, we have to find an a such that
--
-- > b ~ F a /\ Show a /\ FInv (F a) ~ a
--
-- Introducing an intermeidate variable `x` for the result of `F a` gives us
--
-- > b ~ F a /\ Show a /\ FInv x ~ a /\ F a ~ x
--
-- Simplifying
--
-- > b ~ x /\ Show a /\ FInv x ~ a /\ F a ~ x
--
-- Set x := b
--
-- > Show a /\ FInv b ~ a /\ F a ~ b
--
-- Set a := FInv b
--
-- > Show (FInv b) /\ FInv b ~ FInv b /\ F (FInv b) ~ b
--
-- Simplifying
--
-- > Show (FInv b) /\ F (FInv b) ~ b
--
-- Indeed, we can give this definition in 7.8, but not in 7.10:
showFromF'
::
(
Show
(
FInv
b
),
F
(
FInv
b
)
~
b
)
=>
b
->
String
showFromF'
=
showFromF
{-------------------------------------------------------------------------------
In 7.10 the definition of showFromF' is not accepted, but it gets stranger.
In 7.10 we cannot _call_ showFromF at all all, even at a concrete type. Below
we try to call it at type b ~ Int. It would need to show
> Show (FInv Int) /\ F (FInt Int) ~ Int
all of which should easily get resolved, but somehow don't.
-------------------------------------------------------------------------------}
type
instance
F
Int
=
Int
type
instance
FInv
Int
=
Int
test
::
String
test
=
showFromF
(
0
::
Int
)
testsuite/tests/indexed-types/should_compile/all.T
View file @
d4a926ba
...
...
@@ -254,4 +254,4 @@ test('T10020', normal, compile, [''])
test
('
T10079
',
normal
,
compile
,
[''])
test
('
T10139
',
normal
,
compile
,
[''])
test
('
T10340
',
normal
,
compile
,
[''])
test
('
T10226
',
normal
,
compile
,
[''])
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