GHC: Ticket #1037: primRepHint:VoidRep <p> Compiling this module: </p> <pre class="wiki">module Q where import GHC.Base type World__ = State# RealWorld foreign import ccall unsafe "putwchar" f :: World__ -&gt; Char# -&gt; World__ </pre><p> with <tt>ghc -fglasgow-exts -O Q.hs</tt> panics: </p> <pre class="wiki">ghc-6.6: panic! (the 'impossible' happened) (GHC version 6.6 for x86_64-unknown-linux): primRepHint:VoidRep </pre><p> It looks like we need a VoidHint if we want to support this. </p> <p> Reported by John Meacham in <a class="ext-link" href=""><span class="icon">​</span></a> </p> en-us GHC Trac 1.0.1 simonmar Mon, 04 Dec 2006 12:45:50 GMT <p> I think the typechecker ought to be rejecting this foreign declaration, I don't believe State# is supposed to be among the valid return types for a foreign import. Why can't IO () be used here? </p> Ticket igloo Mon, 04 Dec 2006 13:14:56 GMT <p> The time this sort of stuff is desirable is when you want to return unboxed values in the IO monad, as you can't have an IO Char# type. </p> <p> However, the optimiser will currently eliminate the boxing done by the generated import wrapper and the unboxing done in the Haskell code that uses the import. </p> <p> So it's not vital that this is done, but it would mean people don't have to rely on the optimiser always catching this sort of thing. It is only useful if you are writing (or generating) very low level stuff, though. </p> Ticket simonpj Thu, 09 Aug 2007 10:16:02 GMT status changed; testcase, resolution set <ul> <li><strong>status</strong> changed from <em>new</em> to <em>closed</em> </li> <li><strong>testcase</strong> set to <em>ccfail001</em> </li> <li><strong>resolution</strong> set to <em>fixed</em> </li> </ul> <p> It makes *sense* for a foreign import to have a zero-sized return, thus </p> <pre class="wiki"> foreign import ccall foo :: Int -&gt; State# RealWorld </pre><p> but it's not clear that it's useful, and it requires some back-end (a Hint for void types) to make it go right through the back end. It's not clear that we really want this facility, so rather than fixing the code generator, I'm just making the construct illegal for now. </p> Ticket igloo Mon, 05 Nov 2007 15:03:54 GMT milestone changed <ul> <li><strong>milestone</strong> changed from <em>6.8 branch</em> to <em>6.8.1</em> </li> </ul> Ticket simonmar Tue, 30 Sep 2008 15:40:05 GMT architecture changed <ul> <li><strong>architecture</strong> changed from <em>Unknown</em> to <em>Unknown/Multiple</em> </li> </ul> Ticket simonmar Tue, 30 Sep 2008 15:51:11 GMT os changed <ul> <li><strong>os</strong> changed from <em>Unknown</em> to <em>Unknown/Multiple</em> </li> </ul> Ticket