GHC: Ticket Queryhttp://ghc.haskell.org/trac/ghc/query?status=!closed&version=7.0.4&desc=1&order=priority
The Glasgow Haskell Compileren-USGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.pnghttp://ghc.haskell.org/trac/ghc/query?status=!closed&version=7.0.4&desc=1&order=priority
Trac 1.0.1http://ghc.haskell.org/trac/ghc/ticket/5316
http://ghc.haskell.org/trac/ghc/ticket/5316#5316: Orphan instances strike again: ghc rejects a program at first but will accept it if you repeat the same compilation commandMon, 11 Jul 2011 20:24:10 GMTjcpetruzza<p>
Consider these two modules (boiled down example from the checkers package):
</p>
<pre class="wiki">{-# LANGUAGE ScopedTypeVariables, FlexibleContexts #-}
module T1
where
import Test.QuickCheck
import Text.Show.Functions ()
f :: forall m a b. ( Arbitrary (a-&gt;b) ) =&gt; m (a,b) -&gt; Property
f = const $ property (undefined :: (a-&gt;b) -&gt; Bool)
</pre><pre class="wiki">module T2 where
import Control.Concurrent
g = threadDelay maxBound
</pre><p>
I see the following interaction:
</p>
<pre class="wiki">$ rm *hi *.o
$ ghc --make -c -O T1 T2
[1 of 2] Compiling T2 ( T2.hs, T2.o )
[2 of 2] Compiling T1 ( T1.hs, T1.o )
T1.hs:12:13:
Overlapping instances for Show (a -&gt; b)
arising from a use of `property'
Matching instances:
instance Show (a -&gt; b) -- Defined in Text.Show.Functions
instance Show base:System.Event.Manager.IOCallback
-- Defined in base:System.Event.Manager
(The choice depends on the instantiation of `a, b'
To pick the first instance above, use -XIncoherentInstances
when compiling the other instance declarations)
In the second argument of `($)', namely
`property (undefined :: (a -&gt; b) -&gt; Bool)'
In the expression: const $ property (undefined :: (a -&gt; b) -&gt; Bool)
In an equation for `f':
f = const $ property (undefined :: (a -&gt; b) -&gt; Bool)
$ ghc --make -c -O T1 T2
[2 of 2] Compiling T1 ( T1.hs, T1.o )
$ ghc --make -c -O T1 T2
$ ls
T1.hi T1.hs T1.o T2.hi T2.hs T2.o
</pre><p>
I see this consistent behaviour in versions 7.0.{1,2,3,4} but not with 6.12.1
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5316#changeloghttp://ghc.haskell.org/trac/ghc/ticket/5376
http://ghc.haskell.org/trac/ghc/ticket/5376#5376: Quotation in System.Process.system for WindowsThu, 04 Aug 2011 06:58:28 GMTsimonpj<p>
Wagnerdm writes: I had a bit of fun recently tracking down quoting issues with the "<tt>system</tt>" command in Windows. For the examples below, I'll consistently use "<tt>Windows&gt; </tt>" as the beginning of some text sent to the Windows command prompt cmd.exe, and use "<tt>GHC&gt; </tt>" as the beginning of some text sent to a ghci session running in cmd.exe with <tt>System.Cmd</tt> imported.
</p>
<p>
The situation is this: I want to hand off a command line which has both a possibly-quoted command name and a (definitely) quoted argument. For concreteness, let's use "more" as the command and "foo.txt" as the argument, so that you can follow along at home on your favorite Windows system.
</p>
<pre class="wiki">Windows&gt; echo foo &gt; foo.txt
Windows&gt; "more" "foo.txt"
foo
</pre><p>
All good so far. But:
</p>
<pre class="wiki">GHC&gt; system "\"more\" \"foo.txt\""
'more" "foo.txt' is not recognized as an internal or external command, operable program or batch file.
ExitFailure 1
</pre><p>
After some digging, I discovered that system is shipping out to cmd /c, and indeed:
</p>
<pre class="wiki">Windows&gt; cmd /c "more" "foo.txt"
'more" "foo.txt' is not recognized as an internal or external command, operable program or batch file.
</pre><p>
I don't know what the *right* fix is. However, after a bit of playing around, I discovered the following:
</p>
<pre class="wiki">Windows&gt; cmd /c ""more" "foo.txt""
foo
GHC&gt; system "\"\"more\" \"foo.txt\"\""
foo
ExitSuccess
</pre><p>
Wrapping commands with an extra pair of double-quotes this way seemed to give behavior matching the bare cmd.exe for all the examples I could think of, even ones I thought it would break. For example:
</p>
<pre class="wiki">GHC&gt; system "\"more foo.txt\""
foo
ExitSuccess
</pre><p>
If this turns out to be the right thing to do, it's pretty easy to implement. In the <tt>commandToProcess</tt> function, at <tt>libraries/process/System/Process/Internals.hs:455</tt>, the change is just
</p>
<pre class="wiki">- return (cmd, translate cmd ++ "/c " ++ string)
+ return (cmd, translate cmd ++ "/c \"" ++ string ++ "\"")
</pre><p>
(And in any case, the examples above should answer this amusing comment, immediately following those lines:
</p>
<pre class="wiki"> -- We don't want to put the cmd into a single
-- argument, because cmd.exe will not try to split it up. Instead,
-- we just tack the command on the end of the cmd.exe command line,
-- which partly works. There seem to be some quoting issues, but
-- I don't have the energy to find+fix them right now (ToDo). --SDM
-- (later) Now I don't know what the above comment means. sigh.
</pre><p>
Later, Brandon comments: What that comment means is that how CMD.EXE handles spaces is Windows-version-dependent. On the other hand, I <em>think</em> it's mostly consistent between XP and Windows 7 --- and I feel sorry for anyone forced to use an older version.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5376#changeloghttp://ghc.haskell.org/trac/ghc/ticket/8258
http://ghc.haskell.org/trac/ghc/ticket/8258#8258: GHC accepts `data Foo where` in H2010 modeMon, 09 Sep 2013 08:49:14 GMThvr<p>
According to the Haskell2010 report,
</p>
<p>
The grammar productions relevant for <tt>data</tt> declarations are the following:
</p>
<pre class="wiki">topdecl → data [context =&gt;] simpletype [= constrs] [deriving]
</pre><p>
(from <a class="ext-link" href="http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2"><span class="icon">​</span>4.2.1 Algebraic Datatype Declarations</a>)
</p>
<p>
However, GHC 7.0.4/7.4.2/7.6.3/HEAD all happily compile the following Haskell module without any warning when using <tt>-XHaskell2010 -Wall</tt>, even though this is not valid Haskell2010 afaik:
</p>
<div class="code"><pre><span class="kr">module</span> <span class="nn">Foo</span> <span class="kr">where</span>
<span class="kr">data</span> <span class="kt">Foo</span> <span class="kr">where</span>
</pre></div><p>
The trailing <tt>where</tt> in the <tt>data</tt> declaration is not valid Haskell2010 (without language extensions such as <tt>GADT</tt>).
</p>
<p>
At the very least, this divergence from the Haskell Report should be mentioned in <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs-and-infelicities.html#haskell-standards-divergence">14.1.1. Divergence from Haskell 98 and Haskell 2010</a>.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/8258#changeloghttp://ghc.haskell.org/trac/ghc/ticket/5369
http://ghc.haskell.org/trac/ghc/ticket/5369#5369: Reinstate VECTORISE pragmas with expressions as right-hand sidesTue, 02 Aug 2011 08:23:47 GMTsimonpj<p>
The current vectoriser depends in a very fragile way on the order in which the constraint solver generates constraints. This ticket is just to track this known problem.
</p>
<p>
Manifestation:
</p>
<pre class="wiki">*** Vectorisation error ***
Type mismatch in vectorisation pragma for Data.Array.Parallel.unzipP
Expected type forall a_a1SF b_a1SG.
(Data.Array.Parallel.PArray.PRepr.PA a_a1SF,
Data.Array.Parallel.PArray.PRepr.PA b_a1SG) =&gt;
Data.Array.Parallel.PArray.Base.PArray (a_a1SF, b_a1SG)
Data.Array.Parallel.Lifted.Closure.:-&gt; (Data.Array.Parallel.PArray.Base.PArray
a_a1SF,
Data.Array.Parallel.PArray.Base.PArray
b_a1SG)
Inferred type forall a_a21g b_a21h.
(Data.Array.Parallel.PArray.PRepr.PA b_a21h,
Data.Array.Parallel.PArray.PRepr.PA a_a21g) =&gt;
Data.Array.Parallel.PArray.Base.PArray (a_a21g, b_a21h)
Data.Array.Parallel.Lifted.Closure.:-&gt; (Data.Array.Parallel.PArray.Base.PArray
a_a21g,
Data.Array.Parallel.PArray.Base.PArray
b_a21h)
</pre><p>
Reason: the compilation of VECTORISE pragmas depends on the order of constraints in an inferred type. This isn't trivial to fix. As Manuel writes, the problem here is that we do not know what wrapper w we need *until* the vectoriser runs. Why is that? Given
</p>
<pre class="wiki"> f :: ty
f = e
{-# VECTORISE f = e_v #-}
</pre><p>
where the type *inferred* for <tt>e_v</tt> is <tt>ty_v</tt>, we need to mediate between <tt>ty_v</tt> and <tt>V[[ty]]</tt>. (Here <tt>V[[ty]]</tt> is the transformation that maps a regular type to a vectorised type.)
</p>
<p>
It is <tt>V[[ty]]</tt> that we cannot determine until the vectoriser runs. If we could compute <tt>V[ty]]</tt> in the type checker, we could use it together with <tt>ty_v</tt> to compute a wrapper w as you propose.
</p>
<p>
Alas, given the current implementation of <tt>V[[..]]</tt> in the vectoriser (it is implemented in <tt>Vectorise.Type.vectType</tt>), we cannot call it in the type checker, because it runs in the <tt>VM</tt> monad, which is a variant of the 'DsM' monad. In particular, 'VM' uses some tables of names of types and functions defined in the DPH library that are not available during type checking. (I briefly considered duplicating the code for <tt>vectType</tt> as a stop gap measure in <tt>TcM</tt>, but that didn't seem to be so easy.)
</p>
<p>
I believe that the Right Thing to do is to change the 'VM' monad and the implementation of <tt>vectType</tt>, so that it is more flexible and can be called from <tt>TcM</tt>. The changes that I am making at the moment (i.e., cutting down these tables of magic, built-in things) will make it easier to improve <tt>vectType</tt>.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5369#changeloghttp://ghc.haskell.org/trac/ghc/ticket/5392
http://ghc.haskell.org/trac/ghc/ticket/5392#5392: Warnings about impossible MPTCs would be niceMon, 08 Aug 2011 17:06:16 GMTpumpkin<p>
In the following class declaration:
</p>
<pre class="wiki">{-# LANGUAGE MultiParamTypeClasses #-}
class C a b where
f :: a -&gt; a
</pre><p>
it is possible to declare this class, and to make instances of it, but it will be impossible to ever call <tt>f</tt>, even with <tt>unsafeCoerce</tt> and other evil attempted workarounds. It seems fairly easy for GHC to spot this situation, where a method doesn't mention all of the class arguments, and it might save some confusion for newbies. I remember trying pretty hard when I was first learning haskell to tell GHC which instance I wanted there, but obviously failed quite miserably.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5392#changeloghttp://ghc.haskell.org/trac/ghc/ticket/5400
http://ghc.haskell.org/trac/ghc/ticket/5400#5400: GHC loops on compiling with optimizationsWed, 10 Aug 2011 05:49:12 GMTnoschinl<p>
When compiling the snippet below with optimizations enabled (i.e. <tt>ghc -O test.hs</tt>), GHC does not seem to terminate. This happens with at least 7.0.3 and 7.0.4. Without optimizations, it builds fine.
</p>
<pre class="wiki">data A = A Int
class C a where
fromHsk :: C a =&gt; a -&gt; Int
instance C Int where
fromHsk = fromHsk
instance C A where
fromHsk (A s) = fromHsk s
main = undefined
</pre><p>
When building this example with GHC 6.12.4, it fails with a complaint about the bogus type constraints in the declaration of fromHsk:
</p>
<pre class="wiki">test.hs:3:0:
All of the type variables in the constraint `C a'
are already in scope (at least one must be universally quantified here)
(Use -XFlexibleContexts to lift this restriction)
When checking the class method: fromHsk :: (C a) =&gt; a -&gt; Int
In the class declaration for `C'
</pre><p>
After removing these unneeded constraint (i.e. changing the declaration of <tt>fromHsk</tt> to <tt>fromHsk :: a -&gt; Int</tt>, the snippet above builds even with GHC 7.0.4 and optimizations.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5400#changeloghttp://ghc.haskell.org/trac/ghc/ticket/6132
http://ghc.haskell.org/trac/ghc/ticket/6132#6132: Can't use both shebang line and #ifdef declarations in the same file.Tue, 29 May 2012 12:05:29 GMTgfxmonk<p>
I have an (admittedly awkward) script which can be compiled or interpreted.
</p>
<p>
If it's compiled, I want the full goodness. If it's interpreted, I want to run a "minimal" version (because if I don't have the compiled version, I probably don't have the required libraries either).
</p>
<p>
The following almost works:
</p>
<pre class="wiki">
module Main (main) where
#ifdef FANCY
import qualified System.Console.ANSI as Term
start = Term.setSGR [Term.SetColor Term.Foreground Term.Dull Term.Green]
end = Term.setSGR []
#else
start = return ()
end = return ()
#endif
main :: IO ()
main = do
start
putStrLn "hello world"
end
</pre><p>
and then I can do:
</p>
<pre class="wiki">$ runghc -cpp main.hs
hello world
^^ plain text
</pre><pre class="wiki">$ ghc -O -cpp -DFANCY main.hs
$ ./main
hello world
^^ green text (a.k.a "fancy")
</pre><p>
I attempted to make this directly runnable by adding a shebang line of
</p>
<pre class="wiki">#!/usr/bin/runghc -cpp
</pre><p>
But unfortunately that chokes with -cpp:
</p>
<pre class="wiki">
$ ghc -O -cpp -DFANCY main.hs
main.hs:1:0: error: invalid preprocessing directive #!
</pre>Resultshttp://ghc.haskell.org/trac/ghc/ticket/6132#changelog