[GHC] #13884: To an automatic compilation of file-header LANGUAGE pragmas in GHC.
GHC
ghc-devs at haskell.org
Wed Jun 28 07:25:35 UTC 2017
#13884: To an automatic compilation of file-header LANGUAGE pragmas in GHC.
-------------------------------------+-------------------------------------
Reporter: vanto | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by vanto):
Replying to bgamari\\
>>I suspect that making the compiler's behavior conditional on these
heuristics
>>would at best result in some very confusing error messages.\\
Maybe or maybe not. GHC messages should not be underestimated. Here he
answered well.\\
Take a look at this other example.\\
{{{
module Testfoo2 where
import Data.Kind
data Foo (a :: Type) (b :: Type) where
MkFoo :: (a ~ Int, b ~ Char) => Foo a b
}}}
GHC responds\\
{{{
Prelude> :l testfoo2
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:10:16: error:
Illegal kind signature: `Type'
Perhaps you intended to use KindSignatures
In the data type declaration for `Foo'
testfoo2.hs:10:28: error:
Illegal kind signature: `Type'
Perhaps you intended to use KindSignatures
In the data type declaration for `Foo'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:11:1: error:
* Illegal generalised algebraic data declaration for `Foo'
(Use GADTs to allow GADTs)
* In the data declaration for `Foo'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
Ok, modules loaded: Testfoo2.
}}}
If the second function is added
{{{
data family Song (a :: k)
}}}
and that we start again, GHC respond:\\
{{{
*Testfoo2> :l testfoo2
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:13:16: error:
Illegal kind signature: `Type'
Perhaps you intended to use KindSignatures
In the data type declaration for `Foo'
testfoo2.hs:13:28: error:
Illegal kind signature: `Type'
Perhaps you intended to use KindSignatures
In the data type declaration for `Foo'
testfoo2.hs:16:1: error:
Unexpected kind variable `k' Perhaps you intended to use PolyKinds
In the declaration for type family `Song'
testfoo2.hs:16:24: error:
Illegal kind signature: `k'
Perhaps you intended to use KindSignatures
In the declaration for type family `Song'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:16:1: error:
Unexpected kind variable `k' Perhaps you intended to use PolyKinds
In the declaration for type family `Song'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:13:1: error:
* Illegal generalised algebraic data declaration for `Foo'
(Use GADTs to allow GADTs)
* In the data declaration for `Foo'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
testfoo2.hs:16:1: error:
* Illegal family declaration for `Song'
Use TypeFamilies to allow indexed type families
* In the data family declaration for `Song'
Failed, modules loaded: none.
Prelude> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
Ok, modules loaded: Testfoo2.
*Testfoo2> :r
[1 of 1] Compiling Testfoo2 ( testfoo2.hs, interpreted )
Ok, modules loaded: Testfoo2.
}}}
If you look closer you can even remove the pragma {{{ {- # LANGUAGE
KindSignatures # -} }}}
And the program still compiles well. And GHC did it all alone without my
help.\\
I think that has the merit of being studied. You have to be enthusiastic
about doing that. Maybe in twenty years someone will code that? They will
be compilers worthy of the twenty-first century.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13884#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list