Thanks all for your solutions!<br>Here is a summary:<br><br>- floating a value to the top level; then with -Wall GHC will give the type since we didn&#39;t give a value,<br>- adding :: () to the value to check, GHC will complain equally,<br>
- using TemplateHaskell (hereunder),<br>- waiting for the release of the next GHC with TypeHoles.<br><br>Corentin<br><br><div class="gmail_quote">On Sat, Apr 27, 2013 at 8:46 PM, Ilya Portnov <span dir="ltr">&lt;<a href="mailto:portnov@iportnov.ru" target="_blank">portnov@iportnov.ru</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-family:&#39;Ubuntu&#39;;font-size:9pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">÷ ÐÉÓØÍÅ ÏÔ 27 ÁÐÒÅÌÑ 2013 18:55:16 ÐÏÌØÚÏ×ÁÔÅÌØ Corentin Dupont ÎÁÐÉÓÁÌ:<br></p><div><div class="h5">
<p style="margin-top:12px;margin-bottom:12px;margin-left:40px;margin-right:40px;text-indent:0px">Hi Cafe,<br>can I ask the compiler to display the type of an inferred value during compile time?<br>It would be great if I can output a string during compilation with the type.<br>
A little bit like running :type in GHCi, but without GHCi... Because running GHCi is sometime painful (I have to clean my code first).<br><br>I&#39;m thinking of something like:<br><br>main :: IO ()<br>main = do<br>šš a &lt;- someCode<br>
šš displayTypeAtCompileTime a<br>šš return ()<br><br>$ ghc -c test.hs<br>test.hs:4:3: your type is: Foo<br><br>Thanks,<br>Corentin<br></p>
</div></div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Hi.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">What about TemplateHaskell? Smth like:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">{-# LANGUAGE TemplateHaskell #-}</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">module DisplayType where</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">import Language.TH</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">displayTypeAtCompileTime :: Name -&gt; Q Exp</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">displayTypeAtComileTime name = do</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">    reified &lt;- reify name</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">      -- inspect reified structure, see TH haddock documentation</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">    runIO $ putStrLn $ show theType</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">     [| undefined |] -- you need to return some expression; since you are not to use it&#39;s value, it may be even undefined, it seems.</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">###</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">{-# LANGUAGE TemplateHaskell #-}</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">module Main where<br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">import DisplayType</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">main = do</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">...</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">    $displayTypeAtCompileTime &#39;a</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">...</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">š</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">WBR, Ilya Portnov.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>