Last active
August 29, 2015 14:04
-
-
Save YoEight/c154d983f6443d8971d5 to your computer and use it in GitHub Desktop.
Is that a bug ? (GHC 7.8.2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, ExistentialQuantification, RankNTypes #-} | |
data A | |
data B | |
data C | |
data Foo a where | |
FooA :: Foo A | |
FooB :: Foo B | |
FooC :: Foo C | |
data Baz = forall a. Baz (Foo a) | |
unBaz :: (forall a. Foo a -> r) -> Baz -> r | |
unBaz k (Baz x) = k x | |
test :: Baz -> Char -- compile error | |
test = unBaz go where | |
go FooA = 'a' | |
go FooB = 'b' | |
go FooC = 'c' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1 of 1] Compiling Main ( bug.hs, interpreted ) | |
bug.hs:19:13: | |
Couldn't match expected type ‘t’ with actual type ‘Char’ | |
‘t’ is untouchable | |
inside the constraints (t1 ~ A) | |
bound by a pattern with constructor | |
FooA :: Foo A, | |
in an equation for ‘go’ | |
at bug.hs:19:6-9 | |
‘t’ is a rigid type variable bound by | |
the inferred type of go :: Foo t1 -> t at bug.hs:19:3 | |
Relevant bindings include go :: Foo t1 -> t (bound at bug.hs:19:3) | |
In the expression: 'a' | |
In an equation for ‘go’: go FooA = 'a' | |
In an equation for ‘test’: | |
test | |
= unBaz go | |
where | |
go FooA = 'a' | |
go FooB = 'b' | |
go FooC = 'c' | |
bug.hs:20:13: | |
Couldn't match expected type ‘t’ with actual type ‘Char’ | |
‘t’ is untouchable | |
inside the constraints (t1 ~ B) | |
bound by a pattern with constructor | |
FooB :: Foo B, | |
in an equation for ‘go’ | |
at bug.hs:20:6-9 | |
‘t’ is a rigid type variable bound by | |
the inferred type of go :: Foo t1 -> t at bug.hs:19:3 | |
Relevant bindings include go :: Foo t1 -> t (bound at bug.hs:19:3) | |
In the expression: 'b' | |
In an equation for ‘go’: go FooB = 'b' | |
In an equation for ‘test’: | |
test | |
= unBaz go | |
where | |
go FooA = 'a' | |
go FooB = 'b' | |
go FooC = 'c' | |
bug.hs:21:13: | |
Couldn't match expected type ‘t’ with actual type ‘Char’ | |
‘t’ is untouchable | |
inside the constraints (t1 ~ C) | |
bound by a pattern with constructor | |
FooC :: Foo C, | |
in an equation for ‘go’ | |
at bug.hs:21:6-9 | |
‘t’ is a rigid type variable bound by | |
the inferred type of go :: Foo t1 -> t at bug.hs:19:3 | |
Relevant bindings include go :: Foo t1 -> t (bound at bug.hs:19:3) | |
In the expression: 'c' | |
In an equation for ‘go’: go FooC = 'c' | |
In an equation for ‘test’: | |
test | |
= unBaz go | |
where | |
go FooA = 'a' | |
go FooB = 'b' | |
go FooC = 'c' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed by annoting
go
like this:go :: Foo a -> Char
. Thanks @lucasdicioccio