<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sound of a pixel</title>
	<atom:link href="http://twinside.free.fr/dotProject/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://twinside.free.fr/dotProject</link>
	<description>Random dev stuff</description>
	<lastBuildDate>Tue, 07 Dec 2010 13:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>CTagSpotlight</title>
		<link>http://twinside.free.fr/dotProject/?p=230</link>
		<comments>http://twinside.free.fr/dotProject/?p=230#comments</comments>
		<pubDate>Tue, 07 Dec 2010 13:24:46 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[Projets]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=230</guid>
		<description><![CDATA[Today just the small release of a spotlight plugin CtagSpotlight which allow spotlight, the search module of Mac OS X, to index many of your source code and search specific element in it.]]></description>
			<content:encoded><![CDATA[<p>Today just the small release of a spotlight plugin <a href="https://github.com/Twinside/CTagSpotlight">CtagSpotlight</a> which allow spotlight, the search module of Mac OS X, to index many of your source code and search specific element in it.</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=230</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoSummary</title>
		<link>http://twinside.free.fr/dotProject/?p=226</link>
		<comments>http://twinside.free.fr/dotProject/?p=226#comments</comments>
		<pubDate>Fri, 15 Oct 2010 09:58:41 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[Projets]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=226</guid>
		<description><![CDATA[I almost forgot, A software I made with Fabien Donius, AutoSummary, a PowerPoint 2010 Plug-in. The idea is to give some function of LaTeX&#8217;s beamer module to powerpoint, it&#8217;s a shareware with a fair price (7€). Give it a shot]]></description>
			<content:encoded><![CDATA[<p>I almost forgot, A software I made with Fabien Donius, <a href="http://www.apps-fabrik.com/">AutoSummary</a>, a PowerPoint 2010 Plug-in.</p>

<p>The idea is to give some function of LaTeX&#8217;s beamer module to powerpoint, it&#8217;s a shareware with a fair price (7€). Give it a shot</p>

<p><img src="http://www.apps-fabrik.com/images/screenshot/thumb/ribbon-autosummary-powerpoint-2010.png" alt="AutoSummary screenshot" /></p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=226</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eq 1.0</title>
		<link>http://twinside.free.fr/dotProject/?p=220</link>
		<comments>http://twinside.free.fr/dotProject/?p=220#comments</comments>
		<pubDate>Mon, 11 Oct 2010 12:18:28 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[Projets]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=220</guid>
		<description><![CDATA[Eq 1.0 has been released, it&#8217;s now Open Source and available on Github/Hackage and some binary will follow. Eq info page (rather light for the moment, binary will be put here). documentation Eq on Hackage Eq on github]]></description>
			<content:encoded><![CDATA[<p>Eq 1.0 has been released, it&#8217;s now Open Source and available on Github/Hackage and some binary will follow.</p>

<ul>
<li><a href="/eq">Eq info page</a> (rather light for the moment, binary will be put here).</li>
<li><a href="/eq/doc">documentation</a></li>
<li>Eq on <a href="http://hackage.haskell.org/package/Eq">Hackage</a></li>
<li>Eq on <a href="http://github.com/Twinside/Eq">github</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=220</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SupaView 1.0</title>
		<link>http://twinside.free.fr/dotProject/?p=215</link>
		<comments>http://twinside.free.fr/dotProject/?p=215#comments</comments>
		<pubDate>Sat, 09 Oct 2010 10:39:57 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[English content]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projets]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=215</guid>
		<description><![CDATA[I made a new utility for mac called SupaView, to help you find big files in your hard disk. The software is free (as in beer for the moment), but donation can be made.]]></description>
			<content:encoded><![CDATA[<p>I made a new utility for mac called <a href="../supaview">SupaView</a>, to help you find big files in your hard disk.
<a href="../supaview">
<img src="../supaview/screen.png" />
</a></p>

<p>The software is free (as in beer for the moment), but donation can be made.</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=215</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eq &#8211; Beta</title>
		<link>http://twinside.free.fr/dotProject/?p=185</link>
		<comments>http://twinside.free.fr/dotProject/?p=185#comments</comments>
		<pubDate>Sat, 09 Jan 2010 13:26:03 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[English content]]></category>
		<category><![CDATA[Formule]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projets]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=185</guid>
		<description><![CDATA[I&#8217;m publishing the first beta of my project, a tiny formula manipulation program, which can perform manipulation inside source code or as a calculator on the command line. You can find samples, explaination on the documentation page. The first version only run on Microsoft Windows and Linux in the command line. Next version should be [...]]]></description>
			<content:encoded><![CDATA[<p>
  I&#8217;m publishing the first beta of my project, a tiny formula manipulation program, which can perform manipulation inside source code or as a calculator on the command line. You can find samples, explaination on the <a href="http://twinside.free.fr/eq/doc/">documentation page</a>.
</p>

<p>
<strike>The first version only run on Microsoft Windows and Linux in the command line. Next version should be available on OSX,</strike> and a GUI for Windows will follow.
</p>

<h3>Download</h3>

<p><i>Not available anymore, check for version 1.0.</i>
<center>
<img src="http://twinside.free.fr/dotProject/wp-content/eq_logo_t.png" alt="eq_logo_t" /> 
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=185</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CodeOverview &#8211; RockScroll for gVim</title>
		<link>http://twinside.free.fr/dotProject/?p=179</link>
		<comments>http://twinside.free.fr/dotProject/?p=179#comments</comments>
		<pubDate>Wed, 16 Dec 2009 13:11:07 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[English content]]></category>
		<category><![CDATA[Projets]]></category>
		<category><![CDATA[Technique]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=179</guid>
		<description><![CDATA[Grab it on Vim.org]]></description>
			<content:encoded><![CDATA[<p>
<object width="425" height="344"><param name="movie" value="http://www.youtube-nocookie.com/v/vQqeAk__vvE&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/vQqeAk__vvE&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
</p>

<p>
Grab it on <a href="http://www.vim.org/scripts/script.php?script_id=2888">Vim.org</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=179</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.net using an Haskell DLL</title>
		<link>http://twinside.free.fr/dotProject/?p=167</link>
		<comments>http://twinside.free.fr/dotProject/?p=167#comments</comments>
		<pubDate>Thu, 15 Oct 2009 22:39:32 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[interop]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=167</guid>
		<description><![CDATA[
  The previous post on Eq! shown an application using a bridge between two worlds : Haskell and .net. While there exists library to use .net objects from Haskell (like <a href="http://haskell.forkio.com/dotnet/">hs-dotnet</a>), there is no documentation on how to use Haskell from .net.


An obvious and seemingly easy solution is to go to the Dll route, GHC can make those on windows, .net is good at importing functions in dll. An easy trip in perspective!
]]></description>
			<content:encoded><![CDATA[<p>
  The previous post on Eq! shown an application using a bridge between two worlds : Haskell and .net. While there exists library to use .net objects from Haskell (like <a href="http://haskell.forkio.com/dotnet/">hs-dotnet</a>), there is no documentation on how to use Haskell from .net.
</p>

<p>An obvious and seemingly easy solution is to go to the Dll route, GHC can make those on windows, .net is good at importing functions in dll. An easy trip in perspective!
</p>

<p><span id="more-167"></span></p>

<h3>The Haskell side</h3>

<p>
Ok, we assume that we want a function that take string and output string. As Haskell store characters as Unicode code point and .net is good at Unicode, it&#8217;s better to stay in Unicode in the whole pipeline. So here&#8217;s the haskell code :
</p>

<p><code><pre>
wDoForeign :: (String -> String) -> CWString -> IO CWString
wDoForeign f inCode = do
    inString &lt;- peekCWString inCode
    newCWString $ f inString</p>

<p>wEval :: CWString -> IO CWString
wEval = wDoForeign evalFoo</p>

<p>foreign export ccall "wEval" eqWEval :: CWString -> IO CWString
</pre></code></p>

<p>
wDoForeign is just an helper function to help Marshaling/UnMarshalling the data, wEval wrap the function we really want to expose : evalFoo.
</p>

<p>
Compiling this code yield to the creation to a stub file containing a function wEval, which can be called in C or C++. I won&#8217;t detail how to create the rest of the DLL, as it&#8217;s explained in the <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html">GHC User&#8217;s Guide</a>.
</p>

<p>
Now, let&#8217;s focus on the specifics difference to make if the Dll must be called by .net :
</p>

<p><code><pre>
wchar_t*    dotNetizeW( /<em>out</em>/ wchar_t <em>cHeapString )
{
    size_t length = wcslen( cHeapString );
    wchar_t *out = static_cast<wchar_t</em>>(::CoTaskMemAlloc( (length + 1) * sizeof( wchar_t ) ));</p>

<pre><code>for (int i = 0; i &lt; length; ++i)
    out[i] = cHeapString[i];
out[ length ] = 0;
eqFreeHaskellString( cHeapString );

return out;
</code></pre>

<p>}</p>

<p><strong>attribute</strong>((dllexport)) wchar_t* myExportedFunction( wchar_t <em>in )
        { return dotNetizeW( (wchar_t</em>)wEval( (HsPtr)in ) ); }
</pre></code></p>

<p>
Yes it&#8217;s a bit complex, here eqFreeHaskellString, is an exported haskell function which call free. Documentation says I could use the normal C free, but in case of change, it&#8217;s safe. The problem is you can&#8217;t give simply malloc&#8217;ed data to .net. It use another heap, different from the C one, and this is the role of ::CoTaskMemAlloc to allocate data in the good heap. If you don&#8217;t do this, the function will crash on return. CoTaskMemAlloc is provided by the Ole32 library, so you must have a copy of it around to link against it.
</p>

<p>
Ok now the DLL is ready, there&#8217;s only the easy part on .net.
</p>

<h3>The .net side of things</h3>

<p>
In .net we want to use the DllImport attribute to neatly map haskell function. It&#8217;s easy, two lines of code for each function (don&#8217;t forget the begin &#038; end runtime you must provide in the DLL (see GHC user guide).
</p>

<p><pre><code>
        [DllImport("foo.dll", CharSet = CharSet.Unicode)]
        public static extern string myExportedFunction(string in);
</code></pre></p>

<p>Right? <font color="red">WRONG</font></p>

<p>It was too easy isn&#8217;t it?<br />
Shit happens here.</p>

<p>
For an unknown reason you can&#8217;t simply load the library this way. After some tests in C++, the loader don&#8217;t seem to find the imports in the DLL, the only way to do it seems to use the LoadLibrary and GetProcAdress to retrieve the functions adress manually and then call it. It&#8217;s pretty straightforward in C++, but not so in .net, so here&#8217;s a sample :
</p>

<p><code><pre>
using System.Runtime.InteropServices;
/* other code blah blah blah */
[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibrary(string fileName);</p>

<p>[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);</p>

<p>[return: MarshalAs(UnmanagedType.LPWStr)]
private delegate String Evaluator([MarshalAs(UnmanagedType.LPWStr)][In] String input);</p>

<p>Evaluator ExportedFunc;
</pre></code></p>

<p>
Just few type declarations, as you can see, we introduce a new delegate type matching the type of the Dll function. MarshalAs attributes are important to keep unicode information.
</p>

<p><pre><code>
IntPtr formulaLib = LoadLibrary("myNice.dll");</p>

<p>if (formulaLib == IntPtr.Zero)
    throw new DllNotFoundException("myNice.dll");</p>

<p>IntPtr exportedFunc = GetProcAddress(formulaLib, "myExportedFunction");</p>

<p>if (exportedFunc == IntPtr.Zero)
    throw new MyNiceException("The dll doesn't export the good functions");</p>

<p>ExportedFunc = (Evaluator)Marshal.GetDelegateForFunctionPointer(exportedFunc, typeof(Evaluator));
</code></pre></p>

<p>
And that&#8217;s it. Now, you can normally call ExportedFunc from .net without any problems. You must remember to do the same for the begin/end runtime, call them first from .net, and you&#8217;re done. The gates to Haskell paradise just pop&#8217;ed in your Visual Studio world.
</p>

<h3>Conclusion</h3>

<p>
<strike>
So good luck combining the best of both worlds. I don&#8217;t know if the DLL problem with GHC (version 6.10.4) will be fixed soon or not, but in the mean time you can still use this workaround.</strike>
</p>

<p>
  There is an interesting follow-up in the <a href="http://stackoverflow.com/questions/1494478/call-an-haskell-function-in-net">stackoverflow question</a> explaining how to avoid all my problems in a much nicer way. To bad I didn&#8217; find it myself&#8230;
</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=167</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OCaml in CTags 5.8</title>
		<link>http://twinside.free.fr/dotProject/?p=146</link>
		<comments>http://twinside.free.fr/dotProject/?p=146#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:24:26 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[Projets]]></category>
		<category><![CDATA[ctags]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=146</guid>
		<description><![CDATA[OCaml support is now in CTags svn repository accessible here : svn co https://ctags.svn.sourceforge.net/svnroot/ctags ctags It will be released with CTags 5.8 which should be released soon (within the month). CTags can be downloaded on his website. The final version of the parser is cleaner in it&#8217;s output tags and their contexts, and is fully [...]]]></description>
			<content:encoded><![CDATA[<p>OCaml support is now in CTags svn repository accessible here : 
<code>svn co https://ctags.svn.sourceforge.net/svnroot/ctags ctags</code></p>

<p>
It will be released with CTags 5.8 which should be released soon (within the month). CTags can be downloaded on his <a href="http://ctags.sourceforge.net/">website</a>.
The final version of the parser is cleaner in it&#8217;s output tags and their contexts, and is fully usable with vim and the taglist plugin.
</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=146</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OCaml support for Ctags</title>
		<link>http://twinside.free.fr/dotProject/?p=135</link>
		<comments>http://twinside.free.fr/dotProject/?p=135#comments</comments>
		<pubDate>Tue, 07 Apr 2009 16:49:59 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[English content]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[ctags]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=135</guid>
		<description><![CDATA[Hi, today a post to share a customized version of Ctags with OCaml support. If you don&#8217;t know what Ctags is, you may not want to look at this post. Unless you really, really (did I mention really?) want to be bored. For the few Windows OCaml user, just download ctags57_with_ocaml, and put it where [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, today a post to share a customized version of Ctags with OCaml support. If you don&#8217;t know what Ctags is, you may not want to look at this post. Unless you really, really (did I mention really?) want to be bored.</p>

<p>For the few Windows OCaml user, just download <a href='http://twinside.free.fr/dotProject/?p=146' alt="update on the subject">ctags57_with_ocaml</a>, and put it where you want, maybe in your <code>Windows/System32</code> folder, or in your path.</p>

<p>For Linux/Unix/other user, the patch to integrate OCaml is
<a href="http://twinside.free.fr/dotProject/?p=146" alt="update on the subject">here</a>. It must be applied against Ctag 5.7 avaible <a href="http://twinside.free.fr/dotProject/?p=146" alt="update on the subject">there</a>. Then you have to use some magic incantation to extract/apply patch/compile/install. Good luck with that =]</p>

<p>With a bit of luck, next official version of ctags will support OCaml out of the box.</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=135</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zenburn theme for windows&#8217;s cmd</title>
		<link>http://twinside.free.fr/dotProject/?p=125</link>
		<comments>http://twinside.free.fr/dotProject/?p=125#comments</comments>
		<pubDate>Wed, 04 Mar 2009 13:42:31 +0000</pubDate>
		<dc:creator>Twinside</dc:creator>
				<category><![CDATA[English content]]></category>
		<category><![CDATA[cmd]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[zenburn]]></category>

		<guid isPermaLink="false">http://twinside.free.fr/dotProject/?p=125</guid>
		<description><![CDATA[Today a skin to avoid eye bleeding during work. Adaptation of the famous zenburn theme for vim. To install it, you just have to apply the reg file below. zenburn-console]]></description>
			<content:encoded><![CDATA[<p><img src="http://twinside.free.fr/dotProject/wp-content/cmd-zenburn.png" alt="CMD with a zenburn theme" title="cmd-zenburn" /></p>

<p>
Today a skin to avoid eye bleeding during work. Adaptation of the famous <a href="http://slinky.imukuppi.org/zenburnpage/">zenburn</a> theme for vim. To install it, you just have to apply the reg file below.
</p>

<p>
<a href="http://twinside.free.fr/dotProject/wp-content/zenburn-console.reg">zenburn-console</a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://twinside.free.fr/dotProject/?feed=rss2&#038;p=125</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
