<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mostly Code</title>
	<atom:link href="http://mostlycode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mostlycode.wordpress.com</link>
	<description>IT stuff I bumped into</description>
	<lastBuildDate>Tue, 10 Jan 2012 13:48:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mostlycode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mostly Code</title>
		<link>http://mostlycode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mostlycode.wordpress.com/osd.xml" title="Mostly Code" />
	<atom:link rel='hub' href='http://mostlycode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Quote module contents into a string with Template Haskell</title>
		<link>http://mostlycode.wordpress.com/2012/01/10/quote-module-contents-into-a-string-with-template-haskell/</link>
		<comments>http://mostlycode.wordpress.com/2012/01/10/quote-module-contents-into-a-string-with-template-haskell/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 13:45:13 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[template haskell]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=218</guid>
		<description><![CDATA[I have a program with static configuration in module named Config. There is a bunch of constants like this: extractCtxs'ctxSize :: Int extractCtxs'ctxSize = 300 extractCtxs'sparse :: Bool extractCtxs'sparse = True selectWords'dropBorder :: Int selectWords'dropBorder = 20000 selectWords'takeCount :: Int selectWords'takeCount = 100 Now suppose I want to quote this module elsewhere and include it&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=218&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have a program with static configuration in module named Config. There is a bunch of constants like this:</p>
<pre>extractCtxs'ctxSize :: Int
extractCtxs'ctxSize = 300
extractCtxs'sparse :: Bool
extractCtxs'sparse = True
selectWords'dropBorder :: Int
selectWords'dropBorder = 20000
selectWords'takeCount :: Int
selectWords'takeCount = 100</pre>
<p>Now suppose I want to quote this module elsewhere and include it&#8217;s contents into an output file for record: &#8220;This file was produced with the following settings: &lt;Config module contents goes here&gt;&#8221;. There are many ways to do that the simplest being copying the whole module into a string and updating it everytime a change is made.</p>
<p>My solution involves Template Haskell. Turns out you can execute any IO action during compilation. All you really need to do is read a file and produce a literal string containing it. Here is the whole module:</p>
<pre>{-# LANGUAGE TemplateHaskell #-}
module Config where
import Language.Haskell.TH
import Data.List.Split (splitOn)
-- START
-- extractCtxs'dumpSize :: Int
-- extractCtxs'dumpSize = 100000
extractCtxs'ctxSize :: Int
extractCtxs'ctxSize = 300
extractCtxs'sparse :: Bool
extractCtxs'sparse = True
selectWords'dropBorder :: Int
selectWords'dropBorder = 20000
selectWords'takeCount :: Int
selectWords'takeCount = 100
-- STOP
config' = $(do
 s &lt;- runIO $ readFile "lib/Config.hs"
 return $ LitE $ stringL s)
config = head . splitOn "-- STOP" . head . tail . splitOn "-- START" $ config'</pre>
<p>This <a href="https://gist.github.com/4eae297562ae26781b01" target="_blank">gist</a> contains the above module with syntax highlighting. Config.config contains the configuration part. Config.config&#8217; contains the whole module code. Pretty simple, really.</p>
<br /> Tagged: <a href='http://mostlycode.wordpress.com/tag/haskell/'>haskell</a>, <a href='http://mostlycode.wordpress.com/tag/template-haskell/'>template haskell</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=218&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2012/01/10/quote-module-contents-into-a-string-with-template-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Parametric raytracer engine in CUDA &#8211; demo</title>
		<link>http://mostlycode.wordpress.com/2011/02/04/parametric-raytracer-engine-in-cuda-demo/</link>
		<comments>http://mostlycode.wordpress.com/2011/02/04/parametric-raytracer-engine-in-cuda-demo/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 02:03:00 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chmutov]]></category>
		<category><![CDATA[cuda]]></category>
		<category><![CDATA[ray ttracing]]></category>
		<category><![CDATA[screenshots]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=206</guid>
		<description><![CDATA[I&#8217;ve finally finished my raytracer in CUDA yesterday Today I added a quick little feature: screenshots. They can be further processed with mencoder into .avi files and put on Youtube. Just like this one: http://www.youtube.com/watch?v=2xrfezVuhQk I&#8217;ll write something more about the whole thing when I have time for it. In the meantime enjoy some screenshots: ﻿﻿https://github.com/Tener/cuda-course/commit/237ed8d3c1e746d617be5477dd320064fff709c5 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=206&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally finished my raytracer in CUDA yesterday <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Today I added a quick little feature: screenshots. They can be further processed with mencoder into .avi files and put on Youtube.</p>
<p>Just like this one: <a href="http://www.youtube.com/watch?v=2xrfezVuhQk">http://www.youtube.com/watch?v=2xrfezVuhQk</a></p>
<p>I&#8217;ll write something more about the whole thing when I have time for it. In the meantime enjoy some screenshots:</p>
<p><a title="screenshots" href="https://github.com/Tener/cuda-course/commit/237ed8d3c1e746d617be5477dd320064fff709c5" target="_blank">﻿﻿https://github.com/Tener/cuda-course/commit/237ed8d3c1e746d617be5477dd320064fff709c5<br />
</a></p>
<p>They sit in Git repository on GitHub next to the code that generated them.</p>
<br /> Tagged: <a href='http://mostlycode.wordpress.com/tag/chmutov/'>chmutov</a>, <a href='http://mostlycode.wordpress.com/tag/cuda/'>cuda</a>, <a href='http://mostlycode.wordpress.com/tag/ray-ttracing/'>ray ttracing</a>, <a href='http://mostlycode.wordpress.com/tag/screenshots/'>screenshots</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=206&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2011/02/04/parametric-raytracer-engine-in-cuda-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>ffipkg: a neat bindings creation tool. Usage example.</title>
		<link>http://mostlycode.wordpress.com/2011/01/31/ffipkg-a-neat-bindings-creation-tool-usage-example/</link>
		<comments>http://mostlycode.wordpress.com/2011/01/31/ffipkg-a-neat-bindings-creation-tool-usage-example/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 00:20:23 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[build tools]]></category>
		<category><![CDATA[cuda]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[programming tools]]></category>
		<category><![CDATA[bindings]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[curand]]></category>
		<category><![CDATA[ffipkg]]></category>
		<category><![CDATA[hackage]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=185</guid>
		<description><![CDATA[The ﻿FFI Packaging Utility (ffipkg) is a surprisingly easy tool for creating bindings from C to Haskell. It works by processing header files and creating a bunch of modules with accessors to structures, bindings for calling functions and all the usual boilerplate you usually need to write when doing FFI. What it doesn&#8217;t do is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=185&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The ﻿FFI Packaging Utility (<a href="http://www.haskell.org/haskellwiki/FFI_imports_packaging_utility">ffipkg</a>) is a surprisingly easy tool for creating bindings from C to Haskell. It works by processing header files and creating a bunch of modules with accessors to structures, bindings for calling functions and all the usual boilerplate you usually need to write when doing FFI. What it <strong>doesn&#8217;t</strong> do is to provide a nice, high level binding to the underlying C library. But with the boring part worked out we can do it ourselves in Haskell.</p>
<p>In this post I&#8217;ll show how to create a working binding to <a title="CURAND" href="http://developer.download.nvidia.com/compute/cuda/3_2/toolkit/docs/CURAND_Library.pdf" target="_blank">CURAND</a> library. For those unfamiliar with CUDA: CURAND is a library for creating a high-quality pseudo random numbers directly on the graphic card&#8217;s GPU. It works with any recent NVidia card.</p>
<p>First let&#8217;s install <strong>ffipkg</strong> itself. Actually the package name is different &#8211; <strong>hsffig</strong>. What you need to do is:</p>
<pre>$ cabal install hsffig</pre>
<p>There shouldn&#8217;t be any problems with that.</p>
<p>The next step would be installing the CUDA toolkit. If you are on Linux and your distribution provides it prepackaged you can install it with your package manager. Otherwise proceed to <a title="NVidia site" href="http://developer.nvidia.com/object/cuda_3_2_downloads.html" target="_blank">NVidia site</a> and download the right installer.</p>
<p>I used the one for Ubuntu and it worked very well. After running it gently asked for installation prefix and it simply unpacked into it. It also provides you with information on how to configure your system to make libraries and headers visible to the compilers.</p>
<p>Creating the binding library is dead simple. Just create and cd into directory, like this:</p>
<pre>$ mkdir hs-curand &amp;&amp; cd hs-curand</pre>
<p>Then call <strong>ffipkg</strong>:</p>
<pre>$ ffipkg -I${CUDA_INCLUDE_PATH} -L${CUDA_LINK_PATH} -lcurand curand.h</pre>
<p>If the CUDA toolkit is installed system-wide you can omit the extra -I/-L options. Otherwise you should point ffipkg to the right directories, just like you would do with the C/C++ compiler. As an example, I put my installation into ~/localopt/cuda folder and my machine is 64 bit, so in my case I called: <em>(Beware of ~ as it may not be expanded into $HOME)</em></p>
<pre>$﻿ffipkg -I$HOME/localopt/cuda/include -L$HOME/localopt/cuda/lib64 -lcurand curand.h</pre>
<p>This command resulted in 86 files being created in current directory. Notable files:</p>
<ol>
<li>CURAND.cabal &#8211; defines the Cabal library suitable for &#8220;<em>cabal install</em>&#8221; or &#8220;<em>cabal-dev install</em>&#8220;</li>
<li>Setup.hs &#8211; a companion to .cabal file</li>
<li>Makefile &#8211; not to be called directly. (ffipkg will <strong>silently</strong> overwrite whatever Makefile is already in the directory)</li>
<li>A plenty of .hs files for each C datatype declared</li>
<li>Single .hsc file with wrapping code</li>
</ol>
<p>As we examine the files a fun fact becomes apparent: not only did ffipkg provide bindings to CURAND. The bindings to the rest of CUDA are present as well! With a simple command we have created bindings to entire or most of CUDA runtime and driver API along with the CURAND library.</p>
<p>The next step is an actual installation which should go fine:</p>
<pre>$ cabal install</pre>
<p>We have installed a library, but will it actually work? Let&#8217;s find out by writing an example program.</p>
<p>The CURAND documentation itself contains a small program for host API which we will use:</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
/* This program uses the host CURAND API to generate 100
 * pseudorandom floats.
 *
 * Code taken verbatim from CURAND library documentation.
 */
#include
#include
#include
#include
#define CUDA_CALL(x) do { if((x) != cudaSuccess) { \
      printf(&quot;Error at %s:%d\n&quot;,__FILE__,__LINE__);     \
      return EXIT_FAILURE;}} while(0)
#define CURAND_CALL(x) do { if((x) != CURAND_STATUS_SUCCESS) { \
      printf(&quot;Error at %s:%d\n&quot;,__FILE__,__LINE__);            \
      return EXIT_FAILURE;}} while(0)

int main(int argc, char *argv[])
{
  size_t n = 100;
  size_t i;
  curandGenerator_t gen;
  float *devData, *hostData;
  /* Allocate n floats on host */
  hostData = (float *)calloc(n, sizeof(float));
  /* Allocate n floats on device */
  CUDA_CALL(cudaMalloc((void **)&amp;devData, n * sizeof(float)));
  /* Create pseudo-random number generator */
  CURAND_CALL(curandCreateGenerator(&amp;gen,
                                    CURAND_RNG_PSEUDO_DEFAULT));
  /* Set seed */
  CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL));
  /* Generate n floats on device */
  CURAND_CALL(curandGenerateUniform(gen, devData, n));
  /* Copy device memory to host */
  CUDA_CALL(cudaMemcpy(hostData, devData, n * sizeof(float),
                       cudaMemcpyDeviceToHost));
  /* Set seed */
  CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL));
  /* Generate n floats on device */
  CURAND_CALL(curandGenerateUniform(gen, devData, n));
  /* Copy device memory to host */
  CUDA_CALL(cudaMemcpy(hostData, devData, n * sizeof(float),
                       cudaMemcpyDeviceToHost));
  /* Show result */
  for(i = 0; i &lt; n; i++) {     printf(&quot;%1.4f &quot;, hostData[i]);   }   
  printf(&quot;\n&quot;);   
  /* Cleanup */   
  CURAND_CALL(curandDestroyGenerator(gen));   
  CUDA_CALL(cudaFree(devData));   
  free(hostData);   
  return EXIT_SUCCESS; } 
</pre></p>
<p>When executed it will display 100 pseudo random numbers, created from the 1234 seed. For comparison here is Haskell version using our freshly created CURAND bindings:</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;"> {-# LANGUAGE ScopedTypeVariables, CPP #-}
module Main where
import HS_CURAND_H
import System.Environment

type ElType = CFloat

genFun :: Ptr S_curandGenerator_st
       -&gt; Ptr ElType
       -&gt; CSize
       -&gt; IO CInt
genFun = f_curandGenerateUniform

fi :: (Integral a, Num b) =&gt; a -&gt; b
fi = fromIntegral

main :: IO ()
main = do
  args &lt;- getArgs   let n :: (Read a, Num a) =&gt; a
      n = case args of
            [] -&gt; 100
            (n':_) -&gt; read n'

      nBytes = fi (sizeOf (undefined :: ElType) * n)

  -- allocate n data on host
  dataHost :: Ptr ElType &lt;- mallocArray n

  -- allocate n data on device
  dataDevPtr &lt;- malloc
  f_cudaMalloc dataDevPtr nBytes
  dataDev :: Ptr ElType &lt;- peek (castPtr dataDevPtr)
  free dataDevPtr

  -- create pseudo-random number generator
  genPtrPtr &lt;- malloc
  f_curandCreateGenerator genPtrPtr
       (fi e_CURAND_RNG_PSEUDO_DEFAULT)
  genPtr &lt;- peek genPtrPtr
  free genPtrPtr

  -- set seed
  f_curandSetPseudoRandomGeneratorSeed genPtr 1234

  -- generate n data on device
  genFun genPtr dataDev n

  -- copy device memory to host
  f_cudaMemcpy (castPtr dataHost) (castPtr dataDev) nBytes
        (fi e_cudaMemcpyDeviceToHost)

  -- show result
  dataLst &lt;- peekArray n dataHost
  putStr (concatMap (\x -&gt; show x ++ &quot;\n&quot;) dataLst)

  -- cleanup
  f_curandDestroyGenerator genPtr
  f_cudaFree (castPtr dataDev)
  free dataHost

  return ()

</pre></p>
<p>The code is mostly 1-to-1 mapping from C code, as it should be: both programs use the same API functions. The only nuisance in Haskell is the need for extra malloc/free pair whenever API function needs a pointer to variable. This part could (and should!) be done using <a title="alloca" href="http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/Foreign-Marshal-Alloc.html#v:alloca">alloca</a> function in the real world code, but I&#8217;d rather have more understandable version of code here.</p>
<p>After compiling and running this program we will see almost the same output as from the C version. The only difference is caused by different behavior of printf for floats in Haskell and in C. The actual numbers are the same under the hood.</p>
<p>So <strong>ffipkg</strong> has actually created a working Haskell bindings for CUDA and CURAND without any sweat. Like I said already, it&#8217;s pretty low-level &#8211; much like the *-bindings packages on Hackage or even more. This can however serve as a building block for much more Haskell-like API afterwards.</p>
<p>It&#8217;s not always this good. There are a few downsides of ffipkg:</p>
<ol>
<li>It is hard to create a library ready for upload to Hackage</li>
<li>Requires GNU make or equivalent (Makefiles)</li>
<li>Documentation is disabled by default. Even if we enable it in Setup.hs by hand it still doesn&#8217;t provide a lot of useful information.</li>
<li>Exploring the created library hard. My best find: <em>ghci</em> with <em>:+m HS_library-name_H</em></li>
<li>It fails for many packages with unhelpful error message</li>
<li>Sometimes it requires post-processing of created package by hand to make it work</li>
</ol>
<br /> Tagged: <a href='http://mostlycode.wordpress.com/tag/bindings/'>bindings</a>, <a href='http://mostlycode.wordpress.com/tag/c/'>c</a>, <a href='http://mostlycode.wordpress.com/tag/cabal/'>cabal</a>, <a href='http://mostlycode.wordpress.com/tag/cuda/'>cuda</a>, <a href='http://mostlycode.wordpress.com/tag/curand/'>curand</a>, <a href='http://mostlycode.wordpress.com/tag/ffipkg/'>ffipkg</a>, <a href='http://mostlycode.wordpress.com/tag/hackage/'>hackage</a>, <a href='http://mostlycode.wordpress.com/tag/haskell/'>haskell</a>, <a href='http://mostlycode.wordpress.com/tag/linux/'>linux</a>, <a href='http://mostlycode.wordpress.com/tag/make/'>make</a>, <a href='http://mostlycode.wordpress.com/tag/programming/'>programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=185&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2011/01/31/ffipkg-a-neat-bindings-creation-tool-usage-example/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>The taste of CUDA</title>
		<link>http://mostlycode.wordpress.com/2011/01/27/the-taste-of-cuda/</link>
		<comments>http://mostlycode.wordpress.com/2011/01/27/the-taste-of-cuda/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 22:54:27 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=180</guid>
		<description><![CDATA[Recently I was working on some projects using CUDA. Perhaps I will write something more about this experience. Today just a few things to notice: - CUDA is quite low level. If you want to test your algorithm fast, do learn some wrapping library. I tried Thrust &#8211; and it is an excellent library. I&#8217;m [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=180&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on some projects using CUDA. Perhaps I will write something more about this experience. Today just a few things to notice:</p>
<p>- CUDA is quite low level. If you want to test your algorithm fast, do learn some wrapping library. I tried <a href="http://code.google.com/p/thrust/">Thrust</a> &#8211; and it is an excellent library. I&#8217;m speaking here about runtime API: you really shouldn&#8217;t touch driver API if you don&#8217;t have to.</p>
<p>- There is a lot of publicity around CUDA, especially no NVidia sites. But then if you want to get some real information it can be hard to impossible.<br />
- You cannot file a bug report if aren&#8217;t registered developer. Becoming registered developer is no small feat though: judging from application form you <strong>have</strong> to work in some company on some CUDA stuff, provide a web page describing your product (<strong>!</strong>) and some other silly stuff. I still didn&#8217;t get any reply for my application.<br />
- The compiler (NVCC) has it&#8217;s bugs. Only recently I found two of them. One bug was nice enough to provide me with compiler error. Fair enough, perhaps a couple of XOR&#8217;s are too much to handle. Another was more severe: turns out sometimes the usage of -use_fast_math nvcc&#8217;s switch doesn&#8217;t really help. In my case the image that should be the same each frame was mostly random:</p>
<p><a href="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame1.png"><img src="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame1.png" alt="Cuda kernel bug - frame 1" width="311" height="308" /></a><br />
<a href="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame2.png"><img src="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame2.png" alt="Cuda kernel bug - frame 2" width="310" height="309" /></a></p>
<p>Even worse: the actual speed of the code was <strong>100 times worse</strong> with -use_fast_math.</p>
<p>Another thing, not sure if this is bug or not: compiling template-heavy <strong>debugging</strong> code is a nightmare. Each target architecture could take 15 minutes and ~2 Gb (top) memory to compile &#8211; at least this was my experience.</p>
<p>There is plenty of things that are either broken or work poorly here. But on the other hand: CUDA is free as long as you have NVidia card and it really does terrific amount of work under the hood. In specific applications it can perform calculations dramatically faster than CPU.</p>
<p>Unfortunately it&#8217;s extremely easy to shoot your foot here &#8211; so badly you may have to reboot your machine, because the driver got stuck. In the long run I would expect some heavy movement towards higher level languages, most likely with some declarative/functional flavor. (No, C++ is not functional. Boost::lambda is a bad joke, and writing new class each time you want functor is stupid.)</p>
<p>I think one may came up with something like query-execution-evaluator: the programmer would specify the result value and the compiler would then device the best way to calculate it on given machine configuration and data set. All hairy stuff would then go away, since I really believe it&#8217;s too much to handle in the long run.</p>
<p>So far people that use CUDA seem to come from backgrounds that are used to bad code, since they need performance badly. If we want some other people to join in, we need better tools.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=180&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2011/01/27/the-taste-of-cuda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>

		<media:content url="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame1.png" medium="image">
			<media:title type="html">Cuda kernel bug - frame 1</media:title>
		</media:content>

		<media:content url="http://dl.dropbox.com/u/1479187/blog/cuda_kernel_bug_frame2.png" medium="image">
			<media:title type="html">Cuda kernel bug - frame 2</media:title>
		</media:content>
	</item>
		<item>
		<title>It’s JHC’s turn</title>
		<link>http://mostlycode.wordpress.com/2010/07/28/its-jhcs-turn/</link>
		<comments>http://mostlycode.wordpress.com/2010/07/28/its-jhcs-turn/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 21:48:17 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[ffi]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[jhc]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=169</guid>
		<description><![CDATA[It&#8217;s been a while since I wrote here. Today I sat down to try out the relatively new JHC &#8211; Haskell compiler created by John Meacham. After some trivial steps I got it compiled &#38; installed in ~/localopt/jhc-0.7.5/. It worked out of the box. This compiler has a very interesting property: it compiles Haskell code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=169&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I wrote here.</p>
<p>Today I sat down to try out the relatively new <a href="http://repetae.net/computer/jhc/">JHC</a> &#8211; Haskell compiler created by John Meacham.</p>
<p>After some trivial steps I got it compiled &amp; installed in ~/localopt/jhc-0.7.5/. It worked out of the box.</p>
<p>This compiler has a very interesting property: it compiles Haskell code to Ansi C. It can be processed afterwards by any way you want: cross-compiled by gcc or made into shared library. I found the latter to be pretty simple.</p>
<p>The plan is as follows:</p>
<ol>
<li> Create Haskell module and use &#8220;foreign export&#8221; in the file.</li>
<li> Compile it with -fffi and dump C code (-dc).</li>
<li> Use dumped code and a prepared template to compile shared library</li>
</ol>
<p>Simple and clean.</p>
<p>First let&#8217;s create a simple Haskell module with single function &#8220;adder&#8221; and empty &#8220;main&#8221; function.</p>
<p><code>import Foreign<br />
import Foreign.C</code></p>
<p><code> </code></p>
<p><code>foreign export ccall "adder" adder :: CInt -&gt; CInt -&gt; CInt<br />
adder x y = x + y</code></p>
<p><code> </code></p>
<p><code>main :: IO ()<br />
main = return () </code></p>
<p>We will also need library initialization code. Let&#8217;s put it into some known directory, like ~/localopt/jhc-0.7.5/shared/library_init_template.c.</p>
<p><code>#define CAT(a,b) XCAT(a,b)<br />
#define XCAT(a,b) a ## b<br />
#define STR(a) XSTR(a)<br />
#define XSTR(a) #a</code></p>
<p><code> </code></p>
<p><code>extern void CAT (__stginit_, MODULE) (void);</code></p>
<p><code>static void library_init (void) __attribute__ ((constructor));<br />
static void<br />
library_init (void)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;static char *argv[] = { STR (MODULE) ".so", 0 }, **argv_ = argv;<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int argc = 1;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;hs_init(&amp;argc,&amp;argv_);<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (jhc_setjmp(&amp;jhc_uncaught))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jhc_error("Uncaught Exception");</p>
<p>}</p>
<p></code></p>
<p><code>static void library_exit (void) __attribute__ ((destructor));<br />
static void<br />
library_exit (void)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;hs_exit ();<br />
}<br />
</code></p>
<p>Now we can compile the Haskell code:<br />
<code>jhc -fffi -fjgc adder_ffi.hs -o adder.bin -dc</code><br />
The code will be written to file &#8220;adder.bin_code.c&#8221;. We will use it along with the library template above.</p>
<p><code><br />
touch adder_lib.c<br />
cat adder.bin_code.c &gt;&gt; adder_lib.c<br />
cat ~/localopt/jhc-0.7.5/shared/library_init_template.c &gt;&gt; adder_lib.c<br />
</code></p>
<p>Now we can compile it to the shared library. The only thing we need to remember are two macros: -DMODULE=ADDER sets module name in our template, and -D_JHC_STANDALONE=0 disables default main in adder_lib.c. There are also a few default options as used by JHC.</p>
<p><code>gcc -DMODULE=ADDER -D_JHC_STANDALONE=0 -fPIC -shared -Wl,-soname,libadder.so.1 '-std=gnu99' -D_GNU_SOURCE '-falign-functions=4' -ffast-math -Wextra -Wall -Wno-unused-parameter  -o libadder.so.1 adder_lib.c -DNDEBUG -O3 '-D_JHC_GC=_JHC_GC_JGC'</code></p>
<p>Now a simple test program:</p>
<p><code>#include </p>
<p>int adder(int x2,int x3);</p>
<p>int main()<br />
{<br />
  &nbsp;&nbsp;&nbsp;&nbsp;printf("%d\n", adder(3,4));<br />
  &nbsp;&nbsp;&nbsp;&nbsp;return 0;<br />
}<br />
</code></p>
<p><code>gcc -Wl,-rpath=`pwd` libadder.so.1 test_adder.c -o test_adder<br />
./test_adder<br />
7</code></p>
<p>It works!</p>
<p>We can wrap all needed commands into simple script (this is zsh syntax, but bash should be similar or even the same):</p>
<p><code>jhc-shared-lib () {<br />
&nbsp;&nbsp;&nbsp;&nbsp;jhc -fffi -fjgc $1.hs -o $1.bin -dc</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;rm -f $1_lib.c<br />
&nbsp;&nbsp;&nbsp;&nbsp;touch $1_lib.c<br />
&nbsp;&nbsp;&nbsp;&nbsp;cat $1.bin_code.c &gt;&gt; $1_lib.c<br />
&nbsp;&nbsp;&nbsp;&nbsp;cat ~/localopt/jhc-0.7.5/shared/library_init_template.c &gt;&gt; $1_lib.c</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;gcc -D_GNU_SOURCE -DMODULE=ADDER -D_JHC_STANDALONE=0 \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-fPIC -shared -Wl,-soname,lib$1.so.1 \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'-std=gnu99' '-falign-functions=4' -ffast-math \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Wextra -Wall -Wno-unused-parameter \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o lib$1.so.1 $1_lib.c -DNDEBUG -O3 '-D_JHC_GC=_JHC_GC_JGC'<br />
}</code></p>
<p>Invoke it like this:<br />
<code>jhc-shared-lib adder</code></p>
<p>JHC looks like a lot of fun. Even if it doesn&#8217;t support all possible extensions to Haskell it does play really well with C compilers.</p>
<br /> Tagged: <a href='http://mostlycode.wordpress.com/tag/ffi/'>ffi</a>, <a href='http://mostlycode.wordpress.com/tag/functional-programming/'>functional programming</a>, <a href='http://mostlycode.wordpress.com/tag/haskell/'>haskell</a>, <a href='http://mostlycode.wordpress.com/tag/jhc/'>jhc</a>, <a href='http://mostlycode.wordpress.com/tag/linux/'>linux</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=169&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2010/07/28/its-jhcs-turn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>GHC 6.12.1 dynamic executables fun</title>
		<link>http://mostlycode.wordpress.com/2010/01/26/ghc-6-12-1-dynamic-executables-fun/</link>
		<comments>http://mostlycode.wordpress.com/2010/01/26/ghc-6-12-1-dynamic-executables-fun/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 21:46:52 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[build tools]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[programming tools]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=148</guid>
		<description><![CDATA[Recently I started to play with the new GHC 6.12.1. One thing I wanted to do is to link executables with -dynamic flag. It works pretty well when invoked like this: $ ghc --make -dynamic program.hs The resulting program will have plenty of dependencies (50+ is pretty common). It will also be quite small: for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=148&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I started to play with the new GHC 6.12.1. One thing I wanted to do is to link executables with -dynamic flag. It works pretty well when invoked like this:</p>
<pre><code>$ ghc --make -dynamic program.hs
</code></pre>
<p>The resulting program will have plenty of dependencies (50+ is pretty common). It will also be quite small: for example 26K instead of 681K.</p>
<p>However, when building cabalized program/library one would like to have everything done automatically. However <strong>cabal install</strong> doesn&#8217;t make <strong>-dynamic</strong> executables. There is a <a href="http://hackage.haskell.org/trac/hackage/ticket/600" title="Cabal ticket: #600">ticket</a> filled about this on Cabal Trac. One possible workaround is to call <em>cabal install</em> with <em>&#8211;ghc-options=-dynamic</em> flag. The other is to include this flag in <em>ghc-options</em> field in .cabal file. This is better since we can add it selectively. Consider this example binlib:</p>
<pre><code>name: dynbin
version: 0.0
license: BSD3
license-file: LICENSE
copyright: (c) Christopher Skrzetnicki
author: Christopher Skrzetnicki
maintainer: Christopher Skrzetnicki &lt;gtener@gmail.com&gt;
stability: experimental
synopsis:
description:
category: Other
cabal-version: &gt;= 1.2
build-type: Simple

library
  hs-source-dirs: src
  exposed-modules: Dynbin.Main
  build-depends: base == 4.*

executable dynbin-dyn
  executable: dynbin-dyn
  hs-source-dirs: src
  ghc-options: -dynamic
  main-is: dynamic_main.hs

executable dynbin-stat
  executable: dynbin-stat
  hs-source-dirs: src
  main-is: static_main.hs
</code></pre>
<p>Files used are pretty straightforward.</p>
<p><strong>dynamic_main.hs:</strong></p>
<pre><code>import qualified Dynbin.Main

main :: IO ()
main = putStrLn &quot;dynamic_main.hs&quot; &gt;&gt; Dynbin.Main.main
</code></pre>
<p><strong>static_main.hs:</strong></p>
<pre><code>import qualified Dynbin.Main

main :: IO ()
main = putStrLn &quot;static_main.hs&quot; &gt;&gt; Dynbin.Main.main
</code></pre>
<p><strong>Dynbin.Main:</strong></p>
<pre><code>module Dynbin.Main ( main ) where

main :: IO ()
main = putStrLn &quot;Hello from Dynbin.Main.main !!!&quot;
</code></pre>
<p>After installing it works like charm:</p>
<pre><code>$ dynbin-stat
static_main.hs
Hello from Dynbin.Main.main !!!

$ dynbin-dyn
dynamic_main.hs
Hello from Dynbin.Main.main !!!
</code></pre>
<p>Calling <strong>ldd</strong> confirms that first executable is static, and the second is dynamic.</p>
<pre><code>$ ldd `which dynbin-stat`
    linux-gate.so.1 =&gt;  (0xb78dd000)
    librt.so.1 =&gt; /lib/librt.so.1 (0xb78ab000)
    libutil.so.1 =&gt; /lib/libutil.so.1 (0xb78a7000)
    libdl.so.2 =&gt; /lib/libdl.so.2 (0xb78a3000)
    libgmp.so.3 =&gt; /usr/lib/libgmp.so.3 (0xb7856000)
    libm.so.6 =&gt; /lib/libm.so.6 (0xb782f000)
    libc.so.6 =&gt; /lib/libc.so.6 (0xb76e8000)
    libpthread.so.0 =&gt; /lib/libpthread.so.0 (0xb76cf000)
    /lib/ld-linux.so.2 (0xb78de000)

$ ldd `which dynbin-dyn`
    linux-gate.so.1 =&gt;  (0xb77f6000)
    libHSunix-2.4.0.0-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/unix-2.4.0.0/libHSunix-2.4.0.0-ghc6.12.1.so (0xb7765000)
    librt.so.1 =&gt; /lib/librt.so.1 (0xb7734000)
    libutil.so.1 =&gt; /lib/libutil.so.1 (0xb7730000)
    libdl.so.2 =&gt; /lib/libdl.so.2 (0xb772b000)
    libHSbase-4.2.0.0-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/base-4.2.0.0/libHSbase-4.2.0.0-ghc6.12.1.so (0xb72ae000)
    libHSinteger-gmp-0.2.0.0-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/integer-gmp-0.2.0.0/libHSinteger-gmp-0.2.0.0-ghc6.12.1.so (0xb729e000)
    libgmp.so.3 =&gt; /usr/lib/libgmp.so.3 (0xb7251000)
    libHSghc-prim-0.2.0.0-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0-ghc6.12.1.so (0xb71de000)
    libHSrts-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/libHSrts-ghc6.12.1.so (0xb7198000)
    libm.so.6 =&gt; /lib/libm.so.6 (0xb7172000)
    libHSffi-ghc6.12.1.so =&gt; /usr/lib/ghc-6.12.1/libHSffi-ghc6.12.1.so (0xb7169000)
    libc.so.6 =&gt; /lib/libc.so.6 (0xb7022000)
    libpthread.so.0 =&gt; /lib/libpthread.so.0 (0xb7009000)
    /lib/ld-linux.so.2 (0xb77f7000)
</code></pre>
<p>So this is OK for now. But what happens if we choose to have some TH code? Let&#8217;s use some. The following code uses packages <strong>hslogger</strong> and <strong>hslogger-template</strong> to add some logging to our code.</p>
<pre><code>{-# LANGUAGE TemplateHaskell, ForeignFunctionInterface, CPP #-}

module Dynbin.Main ( main ) where

import System.Log.Logger.TH (deriveLoggers)
import qualified System.Log.Logger as HSL
import System.Log.Logger ( updateGlobalLogger, rootLoggerName, setLevel )

$(deriveLoggers &quot;HSL&quot; [HSL.WARNING, HSL.NOTICE, HSL.INFO])

-- dynamic linking
#ifdef MAIN_LIB
main_lib = MAIN_LIB
foreign export ccall MAIN_LIB main :: IO ()
#endif

main :: IO ()
main = do updateGlobalLogger rootLoggerName (setLevel HSL.INFO)
          infoM &quot;Oh hai!&quot;
</code></pre>
<p><strong>dynbin.cabal:</strong></p>
<pre><code>name: dynbin
version: 0.0
license: BSD3
license-file: LICENSE
copyright: (c) Christopher Skrzetnicki
author: Christopher Skrzetnicki
maintainer: Christopher Skrzetnicki &lt;gtener@gmail.com&gt;
stability: experimental
synopsis:
description:
category: Other
cabal-version: &gt;= 1.2
build-type: Simple

library
  hs-source-dirs: src
  exposed-modules: Dynbin.Main
  cpp-options: -DMAIN_LIB=&quot;main_lib&quot;
  build-depends: base == 4.*, hslogger, hslogger-template

executable dynbin-dyn
  executable: dynbin-dyn
  hs-source-dirs: src
  ghc-options: -dynamic
  cpp-options: -DMAIN_LIB=&quot;main_lib&quot;
  main-is: dynamic_dlopen.hs
  other-modules: Paths_dynbin
  build-depends: unix, filepath, directory

executable dynbin-stat
  executable: dynbin-stat
  hs-source-dirs: src
  main-is: static_main.hs
</code></pre>
<p>The static executable builds and works well:</p>
<pre><code>$ dynbin-stat
static_main.hs
Dynbin.Main: Oh hai!
</code></pre>
<p>However, dynbin-dyn doesn&#8217;t. Here is what happens:</p>
<pre><code>Resolving dependencies...
Configuring dynbin-0.0...
Preprocessing library dynbin-0.0...
Preprocessing executables for dynbin-0.0...
Building dynbin-0.0...
Registering dynbin-0.0...
[1 of 2] Compiling Dynbin.Main      ( src/Dynbin/Main.hs, dist/build/dynbin-dyn/dynbin-dyn-tmp/Dynbin/Main.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.3.0.0 ... linking ... done.
Loading package filepath-1.1.0.3 ... linking ... done.
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package old-time-1.0.0.3 ... linking ... done.
Loading package unix-2.4.0.0 ... linking ... done.
Loading package directory-1.0.1.0 ... linking ... done.
Loading package process-1.0.1.2 ... linking ... done.
Loading package time-1.1.4 ... linking ... done.
Loading package random-1.0.0.2 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package syb-0.1.0.2 ... linking ... done.
Loading package base-3.0.3.2 ... linking ... done.
Loading package containers-0.3.0.0 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package parsec-2.1.0.1 ... linking ... done.
Loading package network-2.2.1.7 ... linking ... done.
Loading package hslogger-1.0.7 ... linking ... done.
Loading package pretty-1.0.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package hslogger-template-1.0.0 ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
src/Dynbin/Main.hs:1:0:
    Dynamic linking required, but this is a non-standard build (eg. prof).
    You need to build the program twice: once the normal way, and then
    in the desired way using -osuf to set the object file suffix.
cabal: Error: some packages failed to install:
dynbin-0.0 failed during the building phase. The exception was:
ExitFailure 1
</code></pre>
<p>What does it mean? Well, we can&#8217;t simply mix dynamic builds with TH. I&#8217;m not sure why is it so, but the description how to solve it when using <strong>ghc &#8211;make</strong> is <a href="http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/template-haskell.html#id3029367">here</a>. But here we are in a <strong>cabal install</strong> world. So how we are going to solve it?</p>
<p>There are two solutions. The first, mentioned in discussion for <a href="http://hackage.haskell.org/trac/hackage/ticket/600" title="Cabal ticket: #600">ticket #600</a>, is this: move all executables to a different package and make it depend on the first one. This solution works, but is boring <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Here is a .cabal file for this:</p>
<pre><code>name: dynbin-prog
version: 0.0
license: BSD3
license-file: LICENSE
copyright: (c) Christopher Skrzetnicki
author: Christopher Skrzetnicki
maintainer: Christopher Skrzetnicki &lt;gtener@gmail.com&gt;
stability: experimental
synopsis:
description:
category: Other
cabal-version: &gt;= 1.2
build-type: Simple

executable dynbin-dyn
  executable: dynbin-dyn
  hs-source-dirs: src
  ghc-options: -dynamic
  main-is: dynamic_main.hs
  build-depends: dynbin, base == 4.*

executable dynbin-stat
  executable: dynbin-stat
  hs-source-dirs: src
  main-is: static_main.hs
  build-depends: dynbin, base == 4.*
</code></pre>
<p>There is another solution which is much more fun.</p>
<p><strong>HERE BE DRAGONS</strong></p>
<p>The solution is this: build dynamic library and then use <em>dlopen</em> to open it, then <em>dlsym</em> to select and run specific symbol from the library itself. Pretty simple, huh? So let&#8217;s get to work.</p>
<p>First lest define a common symbol for calling. We might choose to take something from output from this command:</p>
<pre><code>$ nm -D dist/build/libHSdynbin-0.0-ghc6.12.1.so
         w _Jv_RegisterClasses
00002dd8 A __bss_start
         w __cxa_finalize
         w __gmon_start__
         U __stginit_base_Prelude_dyn
000019f8 T __stginit_dynbinzm0zi0_DynbinziMain
000019a4 T __stginit_dynbinzm0zi0_DynbinziMain_dyn
         U __stginit_hsloggerzm1zi0zi7_SystemziLogziLogger_dyn
         U __stginit_hsloggerzmtemplatezm1zi0zi0_SystemziLogziLoggerziTH_dyn
00002dd8 A _edata
00002de0 A _end
00001ad8 T _fini
000014f0 T _init
         U base_GHCziBase_unpackCStringzh_info
         U base_GHCziTopHandler_runIO_closure
00002dc0 D dynbinzm0zi0_DynbinziMain_main_closure
00001984 T dynbinzm0zi0_DynbinziMain_main_info
00002dbc D dynbinzm0zi0_DynbinziMain_main_srt
00002db4 D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs1_closure
00001934 T dynbinzm0zi0_DynbinziMain_zdfmainzuaOs1_info
00002da0 D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs1_srt
00002d80 D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs2_closure
00001674 T dynbinzm0zi0_DynbinziMain_zdfmainzuaOs2_info
00002d90 D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs3_closure
000016f8 T dynbinzm0zi0_DynbinziMain_zdfmainzuaOs3_info
00002dcc D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs_closure
0000199c T dynbinzm0zi0_DynbinziMain_zdfmainzuaOs_info
00002dc8 D dynbinzm0zi0_DynbinziMain_zdfmainzuaOs_srt
         U getStablePtr
         U ghczmprim_GHCziTypes_ZMZN_closure
         U hsloggerzm1zi0zi7_SystemziLog_INFO_closure
         U hsloggerzm1zi0zi7_SystemziLogziLogger_Logger_con_info
         U hsloggerzm1zi0zi7_SystemziLogziLogger_alertM2_closure
         U hsloggerzm1zi0zi7_SystemziLogziLogger_alertM2_info
         U hsloggerzm1zi0zi7_SystemziLogziLogger_saveGlobalLogger1_closure
         U hsloggerzm1zi0zi7_SystemziLogziLogger_saveGlobalLogger1_info
         U hsloggerzm1zi0zi7_SystemziLogziLogger_zdwa_closure
         U hsloggerzm1zi0zi7_SystemziLogziLogger_zdwa_info
         U newCAF
         U rts_apply
         U rts_checkSchedStatus
         U rts_evalIO
         U rts_lock
         U rts_unlock
         U stg_CAF_BLACKHOLE_info
         U stg_IND_STATIC_info
         U stg_gc_ut
         U stg_upd_frame_info
</code></pre>
<p>But this would make the solution even more <a href="http://dwarffortresswiki.net/index.php/Fun">fun</a> than it is already. Instead let&#8217;s take different approach.</p>
<p>We shall export <em>Dynbin.Main.main</em> with <em>foreign export</em> using symbol defined with CPP macro <strong>MAIN_LIB</strong>. Then we shall use the same macro in dynbin-dyn to call the exported symbol. Both simple and fun! Here comes the code:</p>
<p><strong>dynamic_dlopen.hs:</strong></p>
<pre><code>{-# LANGUAGE ForeignFunctionInterface, CPP #-}

{-

Required CPP Macros:
- MAIN_LIB: entry point for dynamic library

-}

module Main(main) where

import System.Posix.DynamicLinker
import System.Directory
import System.FilePath
import Control.Applicative
import Foreign
import Paths_dynbin ( getLibDir )

main_lib = MAIN_LIB

main = do
  libdir &lt;- getLibDir
  print libdir

  shared &lt;- filter (\fn -&gt; takeExtension fn == &quot;.so&quot;) &lt;$&gt; getDirectoryContents libdir
  case shared of
    [] -&gt; error &quot;No shared libraries!&quot;
    [x] -&gt; putStrLn (&quot;One shared lib: &quot; ++ x) &gt;&gt; onShared (libdir &lt;/&gt; x)
    _ -&gt; error &quot;Multiple shared libraries!&quot;

foreign import ccall &quot;dynamic&quot; call_dyn_fun :: FunPtr (IO ()) -&gt; IO ()

dlopen' a1 a2 = print (a1,a2) &gt;&gt; dlopen a1 a2

dlcall :: DL -&gt; String -&gt; IO ()
dlcall dynlib fun = do
  print (dynlib,fun)
  fptr &lt;- dlsym dynlib fun
  case nullFunPtr == fptr of
    False -&gt; call_dyn_fun fptr
    True -&gt; putStrLn =&lt;&lt; dlerror

onShared :: FilePath -&gt; IO ()
onShared libPath = do
  main &lt;- dlopen' libPath [RTLD_LAZY, RTLD_LOCAL]
  dlcall main main_lib
  putStrLn &quot;main_lib exited&quot;
  return ()
</code></pre>
<p><strong>static_main.hs</strong> , unchanged:</p>
<pre><code>import qualified Dynbin.Main

main :: IO ()
main = putStrLn &quot;static_main.hs&quot; &gt;&gt; Dynbin.Main.main
</code></pre>
<p><strong>Dynbin.Main:</strong></p>
<pre><code>{-# LANGUAGE TemplateHaskell #-}

module Dynbin.Main ( main ) where

import System.Log.Logger.TH (deriveLoggers)
import qualified System.Log.Logger as HSL
import System.Log.Logger ( updateGlobalLogger, rootLoggerName, setLevel )

$(deriveLoggers &quot;HSL&quot; [HSL.WARNING, HSL.NOTICE, HSL.INFO])

main :: IO ()
main = do updateGlobalLogger rootLoggerName (setLevel HSL.INFO)
          infoM &quot;Oh hai!&quot;
</code></pre>
<p>And this solution works as expected:</p>
<pre><code>$ dynbin-dyn
&quot;/home/tener//lib/dynbin-0.0/ghc-6.12.1&quot;
One shared lib: libHSdynbin-0.0-ghc6.12.1.so
(&quot;/home/tener//lib/dynbin-0.0/ghc-6.12.1/libHSdynbin-0.0-ghc6.12.1.so&quot;,[RTLD_LAZY,RTLD_LOCAL])
(DLHandle 0x09216080,&quot;main_lib&quot;)
Dynbin.Main: Oh hai!
main_lib exited
$ dynbin-stat
static_main.hs
Dynbin.Main: Oh hai!
</code></pre>
<p>The whole setup is pretty fragile. If you build <strong>run-dyn</strong> without -dynamic flag you will get runtime errors. Note that this behaviour is likely to be linked with this <a href="http://hackage.haskell.org/trac/ghc/ticket/3807" title="#3807">ticket</a>.</p>
<p>Without -dynamic:</p>
<pre><code>$ dynbin-dyn
&quot;/home/tener//lib/dynbin-0.0/ghc-6.12.1&quot;
One shared lib: libHSdynbin-0.0-ghc6.12.1.so
(&quot;/home/tener//lib/dynbin-0.0/ghc-6.12.1/libHSdynbin-0.0-ghc6.12.1.so&quot;,[RTLD_LAZY,RTLD_LOCAL])
dynbin-dyn: user error (dlopen:
        /usr/lib/ghc-6.12.1/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0-ghc6.12.1.so:
        undefined symbol: stg_newByteArrayzh)
</code></pre>
<p><strong>So, what do you think about the whole idea?</strong></p>
<hr />
<p>Configuration used:</p>
<pre><code>$ uname -a
Linux laptener 2.6.32-ARCH #1 SMP PREEMPT Tue Jan 19 06:08:04
       UTC 2010 i686 Intel(R) Core(TM)2 Duo
       CPU T7500 @ 2.20GHz GenuineIntel GNU/Linux
$ cabal -V
cabal-install version 0.8.0
using version 1.8.0.2 of the Cabal library
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 6.12.1
</code></pre>
<p>I also have two non-default flags in my ~/.cabal/config file:</p>
<pre><code>   library-profiling: True
   shared: True
</code></pre>
<br /> Tagged: cabal, config, functional programming, haskell, linux <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=148&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2010/01/26/ghc-6-12-1-dynamic-executables-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Sharing wireless connection with wired computer</title>
		<link>http://mostlycode.wordpress.com/2010/01/07/sharing-wireless-connection-with-wired-computer/</link>
		<comments>http://mostlycode.wordpress.com/2010/01/07/sharing-wireless-connection-with-wired-computer/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:22:59 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[arch linux]]></category>
		<category><![CDATA[dhcp]]></category>
		<category><![CDATA[dnsmasq]]></category>
		<category><![CDATA[ifconfig]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[wicd]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=134</guid>
		<description><![CDATA[Yesterday I wanted to install Arch Linux on a brand new mini computer (with Quad-Core Atom!). I did that on wired connection in one place and then wanted to install additional packages at home. Problem is: I only have wireless connection at home. So I decided I&#8217;ll share wireless connection using my laptop connected to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=134&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I wanted to install Arch Linux on a brand new mini computer (with Quad-Core Atom!). I did that on wired connection in one place and then wanted to install additional packages at home.</p>
<p>Problem is: I only have wireless connection at home. So I decided I&#8217;ll share wireless connection using my laptop connected to a switch. Here is a diagram of my setup:<br />
<a href="http://mostlycode.files.wordpress.com/2010/01/konfig-sara-1.png"><img src="http://mostlycode.files.wordpress.com/2010/01/konfig-sara-1.png?w=300&#038;h=143" alt="Network setup" title="Network setup" width="300" height="143" class="alignnone size-medium wp-image-135" /></a></p>
<p>The hardest part was finding manual how to do this that is on the right level of advancement. There are plenty of descriptions how to create a corporate-level network and configure that with loads of features. And they&#8217;re all far too long and quite an overkill for my purposes.</p>
<p>The solution I came up with comes from many sources, most notably Arch Linux wiki pages about basic routing and dnsmasq. The rest is manual pages and various other sources.</p>
<p>So, how to achieve what I wanted?</p>
<ol>
<li>Enable kernel routing in laptop. Hardly any manual mention that simple step. The temporary solution is to execute command &#8220;echo 1 &gt; /proc/sys/net/ipv4/ip_forward&#8221;. Alternatively in /etc/sysctl.conf set &#8220;net.ipv4.ip_forward=1&#8243;.</li>
<li>Install iptables and dnsmasq. Both are needed for this setup. First one will handle forwarding packets from &#8220;Laptop  sara&#8221; and &#8220;Laptop  router&#8221; subnets. The second is a relatively tiny DNS and DHCP server.</li>
<li>Configure dnsmasq. In router&#8217;s subnet ip&#8217;s are from 192.168.1.1-255 range. dnsmasq will use eth0 interface and assign ip&#8217;s from 192.168.2.2-255 range. Here is /etc/dnsmasq.conf that will do that:<br />
<code>interface=eth0<br />
expand-hosts<br />
domain=localdomain<br />
dhcp-range=192.168.2.2,192.168.2.10,1h<br />
dhcp-host=sara,192.168.2.3 # static assignment<br />
#log-dhcp # usefull for debugging<br />
log-queries # less spam than above, can be left enabled<br />
</code><br />
Of course we need to enable dnsmasq: &#8220;/etc/rc.d/dnsmasq start&#8221;.
</li>
<li>Configure iptables. Simple and fun:<br />
<code>iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE # note the use of 'wlan0' here<br />
/etc/rc.d/iptables save<br />
/etc/rc.d/iptables start</code></p>
<li>192.168.2.1 will be used as eth0&#8242;s address. This one is simple: &#8220;ifconfig eth0 up &amp;&amp; ifconfig eth0 192.168.2.1&#8243;. I also had to turn of wicd connection manager daemon, since it used to disconnect me from wired connection from time to time for no real reason: &#8220;/etc/rc.d/wicd stop&#8221;.</li>
<li>All that is left is making sara ask for assignment: &#8220;sudo dhcpcd&#8221; and done. We are up and running!</li>
</ol>
<br /> Tagged: arch linux, dhcp, dnsmasq, hardware, ifconfig, network, wicd <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=134&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2010/01/07/sharing-wireless-connection-with-wired-computer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>

		<media:content url="http://mostlycode.files.wordpress.com/2010/01/konfig-sara-1.png?w=300" medium="image">
			<media:title type="html">Network setup</media:title>
		</media:content>
	</item>
		<item>
		<title>Shared Haskell .so library with GHC 6.10.4 and Cabal</title>
		<link>http://mostlycode.wordpress.com/2010/01/03/shared-haskell-so-library-with-ghc-6-10-4-and-cabal/</link>
		<comments>http://mostlycode.wordpress.com/2010/01/03/shared-haskell-so-library-with-ghc-6-10-4-and-cabal/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 14:02:40 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[build tools]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[ansi c]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=128</guid>
		<description><![CDATA[I wanted to extend an app written in ANSI C with a functionality written in Haskell. This can be somewhat complicated process. If you use GHC 6.12.1 or newer it can supposedly be easily done with -shared flag. Well, I&#8217;m not sure how it works there, but installing GHC 6.12.1 is a painful process. Instead [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=128&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to extend an app written in ANSI C with a functionality written in Haskell. This can be somewhat complicated process. If you use GHC 6.12.1 or newer it can supposedly be easily done with -shared flag. Well, I&#8217;m not sure how it works there, but installing GHC 6.12.1 is a painful process. Instead I wanted to do the same with GHC 6.10.4. Turns out it can be done with a simple Makefile like this:</p>
<p><code>shared:<br />
&nbsp; &nbsp; &nbsp;	ghc -O --make \<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;	      -no-hs-main -optl '-shared' -optc '-DMODULE=HaskellExts' \<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;	      -o HaskellExts.so src/HaskellExts.hs src/module_init.c<br />
</code></p>
<p>module_init.c is also pretty simple and generic:<br />
<code>#define CAT(a,b) XCAT(a,b)<br />
#define XCAT(a,b) a ## b<br />
#define STR(a) XSTR(a)<br />
#define XSTR(a) #a</p>
<p>#include </p>
<p>extern void CAT (__stginit_, MODULE) (void);</p>
<p>static void library_init (void) __attribute__ ((constructor));<br />
static void<br />
library_init (void)<br />
{<br />
&nbsp; &nbsp; &nbsp;  /* This seems to be a no-op, but it makes the GHCRTS envvar work. */<br />
&nbsp; &nbsp; &nbsp;  static char *argv[] = { STR (MODULE) ".so", 0 }, **argv_ = argv;<br />
&nbsp; &nbsp; &nbsp;  static int argc = 1;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;  hs_init (&amp;argc, &amp;argv_);<br />
&nbsp; &nbsp; &nbsp;  hs_add_root (CAT (__stginit_, MODULE));<br />
}</p>
<p>static void library_exit (void) __attribute__ ((destructor));<br />
static void<br />
library_exit (void)<br />
{<br />
  hs_exit ();<br />
}</code></p>
<p>I took both from <a href="http://wiki.python.org/moin/PythonVsHaskell">http://wiki.python.org/moin/PythonVsHaskell</a>.</p>
<p>Now, this method works in general. However, I wanted to make a .cabal package description, because cabal-install handles some common tasks (like pulling dependencies and cleaning) automatically. This turned out to be little tricky. I had to cheat: the shared library is actually build as executable. Here is the core part of .cabal:</p>
<p><code>executable HaskellExts.so<br />
&nbsp; &nbsp; &nbsp;  build-depends: base == 4.*, directory == 1.0.* , filepath == 1.1.*, edit-distance == 0.1.2.*<br />
&nbsp; &nbsp; &nbsp;  hs-source-dirs: src<br />
&nbsp; &nbsp; &nbsp;  ghc-options: -optl-shared -optc-DMODULE=HaskellExts -no-hs-main<br />
&nbsp; &nbsp; &nbsp;  main-is: HaskellExts.hs<br />
&nbsp; &nbsp; &nbsp;  c-sources: src/module_init.c<br />
&nbsp; &nbsp; &nbsp;  include-dirs: src<br />
&nbsp; &nbsp; &nbsp;  install-includes: HaskellExts.h<br />
&nbsp; &nbsp; &nbsp;  cc-options: -DMODULE=HaskellExts -shared<br />
&nbsp; &nbsp; &nbsp;  ld-options: -shared<br />
</code></p>
<p>I&#8217;m not sure it is the minimal configuration that works. But it works for me so I&#8217;m happy with it. The whole code is available here: <a href="http://dl.dropbox.com/u/1479187/blog/killer-haskell-exts.7z">http://dl.dropbox.com/u/1479187/blog/killer-haskell-exts.7z</a></p>
<br /> Tagged: ansi c, cabal, haskell, linux, make <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=128&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2010/01/03/shared-haskell-so-library-with-ghc-6-10-4-and-cabal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Another day, another release.</title>
		<link>http://mostlycode.wordpress.com/2009/12/05/another-day-another-release/</link>
		<comments>http://mostlycode.wordpress.com/2009/12/05/another-day-another-release/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 19:04:02 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hackage]]></category>
		<category><![CDATA[library wrapper]]></category>
		<category><![CDATA[readline]]></category>
		<category><![CDATA[readline-statevar]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[statevar]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=122</guid>
		<description><![CDATA[It&#8217;s been a rich time in terms of number of packages I&#8217;ve released recently. I&#8217;ve had several half-baked packages on my hard drive I&#8217;ve never actually made polished. I made a decision it can no longer be this way &#8211; I should contribute to the Haskell community I owe so much. Today brings the release [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=122&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a rich time in terms of number of packages I&#8217;ve released recently.</p>
<p>I&#8217;ve had several half-baked packages on my hard drive I&#8217;ve never actually made polished. I made a decision it can no longer be this way &#8211; I should contribute to the Haskell community I owe so much.</p>
<p>Today brings the release of a small wrapping package: readline-statevar. It brings StateVar API for <a href="http://hackage.haskell.org/package/readline">readline</a> package, which wraps <a href="http://www.gnu.org/directory/readline.html">libreadline</a>.</p>
<p>Handful of links:<br />
<a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/67328">Announcement post</a><br />
<a href="http://github.com/Tener/haskell-readline-statevar/">Git repo</a><br />
<a href="http://github.com/Tener/haskell-readline-statevar/issues">Issue tracker</a><br />
<a href="http://hackage.haskell.org/package/readline-statevar">Hackage page</a></p>
<br /> Tagged: cabal, git, hackage, haskell, library wrapper, readline, readline-statevar, release, statevar <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=122&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/12/05/another-day-another-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Kinda sorty</title>
		<link>http://mostlycode.wordpress.com/2009/12/01/kinda-sorty/</link>
		<comments>http://mostlycode.wordpress.com/2009/12/01/kinda-sorty/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 00:24:41 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hackage]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[sorty]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=116</guid>
		<description><![CDATA[I needed a tool to perform relatively simple sorting. An output from &#8216;du -h&#8217; looks like this: ~/ du -a -h cups-pdf 216K cups-pdf/job_41-_stdin_.pdf 2,6M cups-pdf/job_46-202aw__Polska_do_Droga_bez_nazwy_-_Mapy_Google.pdf 424K cups-pdf/job_45-274e_-_Lifestyle_-_studente.pdf 68K cups-pdf/job_44-Google_Maps_API_-_API_Key_Signup.pdf 40K cups-pdf/job_50-Wersja_do_druku___MICKIEWICZA_-_rondo.pdf 136K cups-pdf/job_58-Studia_magisterskie_-_program_po_zmianach_w_roku_2005.pdf 536K cups-pdf/job_40-_stdin_.pdf 1,6M cups-pdf/job_39-_stdin_.pdf 40K cups-pdf/job_52-263j.pdf 104K cups-pdf/job_43-cracking_wpa__Aircrack-ng_.pdf 34M cups-pdf/job_60-DjVu_PostScript_document.pdf 80K cups-pdf/job_56-Bluetooth_GPRS_Howto_-_ArchWiki.pdf 40K cups-pdf/job_51-Wersja_do_druku___Al_Podwale-Palisadowa.pdf 1,1M cups-pdf/job_42-_stdin_.pdf 41M cups-pdf I needed it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=116&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I needed a tool to perform relatively simple sorting. An output from &#8216;du -h&#8217; looks like this:</p>
<p>~/ du -a -h cups-pdf<br />
216K	cups-pdf/job_41-_stdin_.pdf<br />
2,6M	cups-pdf/job_46-202aw__Polska_do_Droga_bez_nazwy_-_Mapy_Google.pdf<br />
424K	cups-pdf/job_45-274e_-_Lifestyle_-_studente.pdf<br />
68K	cups-pdf/job_44-Google_Maps_API_-_API_Key_Signup.pdf<br />
40K	cups-pdf/job_50-Wersja_do_druku___MICKIEWICZA_-_rondo.pdf<br />
136K	cups-pdf/job_58-Studia_magisterskie_-_program_po_zmianach_w_roku_2005.pdf<br />
536K	cups-pdf/job_40-_stdin_.pdf<br />
1,6M	cups-pdf/job_39-_stdin_.pdf<br />
40K	cups-pdf/job_52-263j.pdf<br />
104K	cups-pdf/job_43-cracking_wpa__Aircrack-ng_.pdf<br />
34M	cups-pdf/job_60-DjVu_PostScript_document.pdf<br />
80K	cups-pdf/job_56-Bluetooth_GPRS_Howto_-_ArchWiki.pdf<br />
40K	cups-pdf/job_51-Wersja_do_druku___Al_Podwale-Palisadowa.pdf<br />
1,1M	cups-pdf/job_42-_stdin_.pdf<br />
41M	cups-pdf</p>
<p>I needed it sorted per filesize, which is present in first column. Unfortunately I couldn&#8217;t find a way to do this with &#8220;sort&#8221; utility. So I wrote this tool. It works as it should:</p>
<p>█▓▒░tener@laptener░▒▓██▓▒░ śro gru 02 01:16:12<br />
~/ du -a -h cups-pdf | sorty</p>
<p>40K	cups-pdf/job_50-Wersja_do_druku___MICKIEWICZA_-_rondo.pdf<br />
40K	cups-pdf/job_52-263j.pdf<br />
40K	cups-pdf/job_51-Wersja_do_druku___Al_Podwale-Palisadowa.pdf<br />
68K	cups-pdf/job_44-Google_Maps_API_-_API_Key_Signup.pdf<br />
80K	cups-pdf/job_56-Bluetooth_GPRS_Howto_-_ArchWiki.pdf<br />
104K	cups-pdf/job_43-cracking_wpa__Aircrack-ng_.pdf<br />
136K	cups-pdf/job_58-Studia_magisterskie_-_program_po_zmianach_w_roku_2005.pdf<br />
216K	cups-pdf/job_41-_stdin_.pdf<br />
424K	cups-pdf/job_45-274e_-_Lifestyle_-_studente.pdf<br />
536K	cups-pdf/job_40-_stdin_.pdf<br />
1,6M	cups-pdf/job_39-_stdin_.pdf<br />
1,1M	cups-pdf/job_42-_stdin_.pdf<br />
2,6M	cups-pdf/job_46-202aw__Polska_do_Droga_bez_nazwy_-_Mapy_Google.pdf<br />
34M	cups-pdf/job_60-DjVu_PostScript_document.pdf<br />
41M	cups-pdf</p>
<p>I&#8217;ve put it on Hackage <a href="http://hackage.haskell.org/package/sorty">here</a>, and the repo is on GitHub <a href="http://github.com/Tener/haskell-sorty">here</a>.</p>
<br /> Tagged: cabal, du, git, hackage, haskell, linux, shell, sorting, sorty <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=116&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/12/01/kinda-sorty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Released package-vt-0.1.3.3</title>
		<link>http://mostlycode.wordpress.com/2009/11/27/released-package-vt-0-1-3-3/</link>
		<comments>http://mostlycode.wordpress.com/2009/11/27/released-package-vt-0-1-3-3/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 02:48:10 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming tools]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[cabal]]></category>
		<category><![CDATA[hackage]]></category>
		<category><![CDATA[package-vt]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=111</guid>
		<description><![CDATA[Just a quick update now. I&#8217;ve just released a brand new tool called package-vt. It should be used for detecting changes in packages that should cause a version bump. You can read more on Haskell Cafe. Page on Hackage. Git repo. Stay tuned for more info! Tagged: cabal, hackage, haskell, package-vt, release<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=111&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick update now. I&#8217;ve just released a brand new tool called package-vt. It should be used for detecting changes in packages that should cause a version bump. </p>
<p>You can read more on <a href="http://www.haskell.org/pipermail/haskell-cafe/2009-November/069692.html">Haskell Cafe</a>.<br />
Page on <a href="http://hackage.haskell.org/package/package-vt">Hackage</a>.<br />
Git <a href="http://github.com/Tener/haskell-package-vt">repo</a>.</p>
<p>Stay tuned for more info!</p>
<br /> Tagged: cabal, hackage, haskell, package-vt, release <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=111&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/11/27/released-package-vt-0-1-3-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Rsync over ssh with custom port</title>
		<link>http://mostlycode.wordpress.com/2009/11/14/rsync-over-ssh-with-custom-port/</link>
		<comments>http://mostlycode.wordpress.com/2009/11/14/rsync-over-ssh-with-custom-port/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 18:04:03 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[utility]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=107</guid>
		<description><![CDATA[It&#8217;s just a quick tip. How can you force rsync to use a specific port when connecting to remote machine via ssh? Turns out it&#8217;s pretty easy, if you dig into man page deep enough. Simply specify needed port in &#8216;-e&#8217; option like this: rsync -av -e "ssh -p 123" example.com:/path/on/remote/server ~/local/path As a bonus, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=107&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s just a quick tip. How can you force rsync to use a specific port when connecting to remote machine via ssh? Turns out it&#8217;s pretty easy, if you dig into man page deep enough. Simply specify needed port in &#8216;-e&#8217; option like this:</p>
<p><code>rsync -av -e "ssh -p 123" example.com:/path/on/remote/server ~/local/path</code></p>
<p>As a bonus, with the same option you can add a lot more useful options, like compression and compression ratio:</p>
<p><code>... -e "ssh -p 123 -C -oCompressionLevel=9" ... </code></p>
<br /> Tagged: rsync, server, shell, ssh, tips <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=107&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/11/14/rsync-over-ssh-with-custom-port/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;m not dead</title>
		<link>http://mostlycode.wordpress.com/2009/11/10/im-not-dead/</link>
		<comments>http://mostlycode.wordpress.com/2009/11/10/im-not-dead/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 01:51:14 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[metablog]]></category>
		<category><![CDATA[creativity]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=105</guid>
		<description><![CDATA[&#8230; yet. It&#8217;s actually quite the opposite: I&#8217;m alive but quite busy. It&#8217;s hard for me to find any time to write anything for the blog. I&#8217;ve been writing quite a lot recently, most of which you can read in this article. To be more specific: I wrote an introductory article about basics of Haskell [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=105&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230; yet. It&#8217;s actually quite the opposite: I&#8217;m alive but quite busy. It&#8217;s hard for me to find any time to write anything for the blog. I&#8217;ve been writing quite a lot recently, most of which you can read in <a href="http://informatyka.wroc.pl/node/283">this article</a>.</p>
<p>To be more specific: I wrote an introductory article about basics of Haskell for a polish computer science portal. I put quite some effort in it (~25h), but I hope there are people that will benefit from it greatly.</p>
<br /> Tagged: creativity, haskell, job, writing <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=105&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/11/10/im-not-dead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Haskell jobs</title>
		<link>http://mostlycode.wordpress.com/2009/10/26/haskell-jobs/</link>
		<comments>http://mostlycode.wordpress.com/2009/10/26/haskell-jobs/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 09:59:53 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=99</guid>
		<description><![CDATA[Recently I&#8217;ve been looking for a job involving Haskell or functional programming in general. No luck. I know that there are is page in Haskell wiki about that, but it&#8217;s almost empty, if I filter out those which doesn&#8217;t match my preferences. First thing is: most companies are from US. Next came UK finance companies [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=99&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been looking for a job involving Haskell or functional programming in general. No luck. I know that there are is <a href="http://www.haskell.org/haskellwiki/Jobs">page</a> in Haskell wiki about that, but it&#8217;s almost empty, if I filter out those which doesn&#8217;t match my preferences.</p>
<p>First thing is: most companies are from US. Next came UK finance companies (like Barclays or Credit Suisse), which are way too far for me. There are also a couple of links to now-dead startups that meant to use Haskell as a silver bullet. No luck I suppose. The one interesting company listed there is <a href="http://www.starling-software.com">Starling Software</a>. Too bad they are from Japan. Another notable exception is <i><a href="http://erlang-consulting.com/">Erlang Training and Consulting Ltd</a></i>. Sadly, while they do have an office in <a href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=krakow,+poland&amp;sll=37.0625,-95.677068&amp;sspn=47.483365,79.013672&amp;ie=UTF8&amp;hq=&amp;hnear=Cracow,+Krakow,+Lesser+Poland,+Poland&amp;z=11">Kraków</a>, they don&#8217;t seem to willing to expand their staff <a href="http://www.erlang-consulting.com/jobs/listing">there</a>.</p>
<p>I also tried several job search engines for a FP job in Poland, without luck.</p>
<p>My research seems to agree with a previous work you can read about <a href="http://mult.ifario.us/p/there-are-apparently-lots-of-haskell-jobs">here</a>.</p>
<p>It is sad that most companies that use FP seem to be either too far away or long dead.</p>
<p>I would really love to see one of those near <a href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=wroc%C5%82aw,+poland&amp;sll=37.0625,-95.677068&amp;sspn=47.483365,79.013672&amp;ie=UTF8&amp;hq=&amp;hnear=Wroc%C5%82aw,+Wroclaw,+Lower+Silesia,+Poland&amp;t=h&amp;z=11">Wrocław</a>.</p>
<br /> Tagged: erlang, functional programming, haskell, job, ocaml <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=99&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/10/26/haskell-jobs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Python web server for documentation</title>
		<link>http://mostlycode.wordpress.com/2009/09/25/python-web-server/</link>
		<comments>http://mostlycode.wordpress.com/2009/09/25/python-web-server/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 23:36:46 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[programming tools]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=81</guid>
		<description><![CDATA[In this blog post we can read about handy way to run a web server to serve files in current directory using Python. I wanted to use it in order to read a documentation for Haskell modules stored locally. Typing python -m SimpleHTTPServer was easy, but I wasn&#8217;t happy with the result. On main page [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=81&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this <a href="http://www.finerrecliner.com/2009/03/01/quick-file-sharing-web-server-in-python/">blog post</a> we can read about handy way to run a web server to serve files in current directory using Python. I wanted to use it in order to read a documentation for Haskell modules stored locally. Typing
<pre>python -m SimpleHTTPServer</pre>
<p> was easy, but I wasn&#8217;t happy with the result. On main page there was index of all modules. That&#8217;s fine. However after choosing one I would see a directory with two entries:</p>
<ol>
<li><strong>html</strong> (directory)</li>
<li><strong>LICENSE</strong> (file)</li>
</ol>
<p>I wanted to skip right into &#8216;html&#8217; directory. Here is code to do just that:<br />
<pre class="brush: python;">
#!/usr/bin/python3

from http.server import *
import http.server
from os import system, chdir
import sys

def run(server_class=HTTPServer, handler_class=http.server.SimpleHTTPRequestHandler):
    server_address = ('', 4000)
    httpd = server_class(server_address, handler_class)
    httpd.serve_forever()

class MyRequestHandler( http.server.SimpleHTTPRequestHandler ):
    def do_GET(self,*args,**kwds):
        tmp = self.path.split('/')
        # redirect?
        if (len(tmp) == 3) and (tmp[0] == tmp[2]) and tmp[0] == '':
            self.send_response(301)
            self.send_header('Location', self.path + 'html/')
        else:
            http.server.SimpleHTTPRequestHandler.do_GET(self,*args,**kwds)

if __name__ == '__main__':
    chdir('/home/tener/share/doc')
    run(handler_class=MyRequestHandler)
</pre></p>
<p>One remark: I decided write code compatible with new Python 3, since that was easy enough and likely to work with new versions for a long time.</p>
<br /> Tagged: documentation, haskell, http, python, server <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=81&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/09/25/python-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Haskell success story</title>
		<link>http://mostlycode.wordpress.com/2009/09/25/haskell-success-story/</link>
		<comments>http://mostlycode.wordpress.com/2009/09/25/haskell-success-story/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 22:41:33 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[haskell]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=95</guid>
		<description><![CDATA[This year I had a information retrieval course. I&#8217;m not a fanboy of Haskell or functional programming, and when the time came to write a program given short time I decided I&#8217;ll do better with Python. I know the language pretty well and did some text processing in it before. There were some significant advantages [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=95&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This year I had a information retrieval course. I&#8217;m not a fanboy of Haskell or functional programming, and when the time came to write a program given short time I decided I&#8217;ll do better with Python. I know the language pretty well and did some text processing in it before.</p>
<p>There were some significant advantages of choosing Python. For one thing, it handles strings pretty well: there are good (read: written in C) procedures that are well designed and suitable for many types of processing. Well&#8230; turns out not <strong>that</strong> many. Pretty quickly I had to resort to using regular expressions, which may be fast, but felt like an overkill.</p>
<p>In theory I knew all the pieces that would compose into my program. The problem of putting them together shouldn&#8217;t be too hard &#8211; and it wasn&#8217;t. The problem was to get this thing working on <strong>my</strong> machine with workload intended. Enter garbage collector nightmare. Turns out Python (or at least <a href="http://en.wikipedia.org/wiki/CPython">CPython</a>, I didn&#8217;t try the others) has a serious problems with it. A program that should do well with constant memory after while can start swapping like mad &#8211; and in practice, never finish the job. I&#8217;ve lost countless hours trying to pin down the bugs in my code that led to this. I still wonder where they are &#8211; and whether they are really fell on my part. I doubt it know. I wrote a lot of code that should solve the problem many times, <strong>if</strong> there was a problem in my code.</p>
<p>I ended up writing all the code in the way they I could do the batch processing. Then I had to write additional code to merge the results. Lots and lots of boilerplate code (with it&#8217;s own share of bugs to smash). I was pretty frustrated and out of schedule. The final product was below my expectations, in terms of both functionalities and code quality, which surely found it way into the final score for the course.</p>
<p>Now you can tell me: it&#8217;s always the same story: too little time, too much to do, hidden problems I didn&#8217;t foresee.</p>
<p>So I&#8217;ll tell you about my experience with Haskell.<br />
Some time later I had to expand my previous task. While I had most of the code in place, it was a complete mess. I designed it to be one, 500-lines at maximum script. I ended up with 1200 lines of code.<br />
So I decided to start from scratch with Haskell. It was refreshing: GC worked well, <a href="http://hackage.haskell.org/package/binary">Binary</a> works much better then Python&#8217;s Pickle (yes, I <strong>did</strong> use the C version&#8230;), and in overall I could easily reuse most of the code. All in all, the resulting code worked much better and had fewer bugs. I also spend half of the time, and didn&#8217;t have any unpleasant discoveries.</p>
<p>Haskell has it&#8217;s own set of pitfalls and shortcomings. But then, every useful programming language has them. The real question is: where are the limits of what can easily be done with it? I haven&#8217;t answered this question for Haskell &#8211; yet. But clearly Haskell allows you more than Python.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=95&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/09/25/haskell-success-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Short Opera review</title>
		<link>http://mostlycode.wordpress.com/2009/09/18/short-opera-review/</link>
		<comments>http://mostlycode.wordpress.com/2009/09/18/short-opera-review/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 15:47:25 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[web utils]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=55</guid>
		<description><![CDATA[Some time ago I decided to give Opera a try. Here is what I learned. Good things about Opera: It has a good RSS reader, better than the one in Firefox for example. Speed Dial: configure it for a bigger screen and you suddenly forget about bookmarks. Definitely better then Firefox&#8217;s &#8216;Bookmark Toolbar&#8217;. Quite fast [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=55&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some time ago I decided to give Opera a try. Here is what I learned.</p>
<p>Good things about Opera:</p>
<ol>
<li>It has a good RSS reader, better than the one in Firefox for example.</li>
<li>Speed Dial: configure it for a bigger screen and you suddenly forget about bookmarks. Definitely better then Firefox&#8217;s &#8216;Bookmark Toolbar&#8217;.</li>
<li>Quite fast rendering.</li>
</ol>
<p>Bad things about Opera:</p>
<ol>
<li>&#8216;Good&#8217; doesn&#8217;t mean &#8216;perfect&#8217;. Opera RSS reader lacks some customizability and restricts the user to have only one feed open at a time.</li>
<li>Widgets. They totally suck.</li>
<li>Stability. I know it&#8217;s beta, but still&#8230;</li>
<li>External plugins just doesn&#8217;t work right. 30% time they hang the whole browser.</li>
<li>Turbo mode: for some reason it confuses JavaScript-driven pages like Gmail.</li>
</ol>
<p>I tested on following version/platform:</p>
<p><strong>Version information</strong><br />
Version<br />
10.00 Beta<br />
Build<br />
4402<br />
Platform<br />
Linux<br />
System<br />
i686, 2.6.30-ARCH<br />
Qt library<br />
3.3.8<br />
Java<br />
Java Runtime Environment installed</p>
<p><strong>Browser identification</strong></p>
<p>Opera/9.80 (X11; Linux i686; U; en) Presto/2.2.15 Version/10.00</p>
<br /> Tagged: firefox, opera, review, rss <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=55&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/09/18/short-opera-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8216;less&#8217; on steroids</title>
		<link>http://mostlycode.wordpress.com/2009/09/11/less-on-steroids/</link>
		<comments>http://mostlycode.wordpress.com/2009/09/11/less-on-steroids/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 10:21:10 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[utility]]></category>
		<category><![CDATA[less]]></category>
		<category><![CDATA[lesspipe]]></category>
		<category><![CDATA[source code highlighting]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=41</guid>
		<description><![CDATA[During the writing about XMonad i got this idea: why not filter source code through colouring program to get a colourful view, and why not do it automatically? Turns out less authors already had this idea &#8216;less&#8217; allows to apply arbitrary filter through the usage of LESSPIPE environmental variable. See man less(1) for details. There [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=41&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>During the writing about XMonad i got this idea: why not filter source code through colouring program to get a colourful view, and why not do it automatically? Turns out less authors already had this idea <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  &#8216;less&#8217; allows to apply arbitrary filter through the usage of LESSPIPE environmental variable. See <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?less">man less(1)</a> for details.</p>
<p>There is already another utility for similar purpose: <a title="Arch Linux 'lesspipe' package" href="http://www.archlinux.org/packages/community/i686/lesspipe/">lesspipe</a>. According to the <a href="http://www-zeuthen.desy.de/~friebel/unix/lesspipe.html">project homepage</a> it can handle various archive formats as well as source code. However, source code is filtered through utility code2color, which I&#8217;m not satisfied with. First of all, it doesn&#8217;t work as supposed to. For some reason it isn&#8217;t called and I really doesn&#8217;t feel like debugging the utility. There are no error messages, so I&#8217;m doesn&#8217;t really know why. Secondly I dislike it&#8217;s design:</p>
<ol>
<li>It&#8217;s a huge, single file with ~3300 lines.</li>
<li>It doesn&#8217;t use any external libraries besides getopt. This means it handles all code coloring itself. This issue also affects #1</li>
<li>As a result, the number of supported languages is small: only 21. <a href="http://hackage.haskell.org/packages/archive/highlighting-kate/0.2.5/doc/html/Text-Highlighting-Kate.html">This package</a> available on Hackage currently supports 56. Including my favorite, Haskell <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ol>
<p>I decided to write my own replacement for lesspipe. I&#8217;m going to post some details about this project soon. Stay tuned!</p>
<br /> Tagged: less, lesspipe, source code highlighting <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=41&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/09/11/less-on-steroids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Current XMonad config</title>
		<link>http://mostlycode.wordpress.com/2009/09/04/current-xmonad-config/</link>
		<comments>http://mostlycode.wordpress.com/2009/09/04/current-xmonad-config/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 10:14:32 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[utility]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[hpaste]]></category>
		<category><![CDATA[xmonad]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=38</guid>
		<description><![CDATA[XMonad is by far the best Window Manager around. It&#8217;s one of the reasons I stick with Linux. It&#8217;s stuffed with great features you can easily compose with your config file to get a fine-tuned behaviour. I decided to post my XMonad config file, since the web is so great as a backup engine Perhaps [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=38&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>XMonad is by far the best Window Manager around. It&#8217;s one of the reasons I stick with Linux. It&#8217;s stuffed with great features you can easily compose with your config file to get a fine-tuned behaviour.</p>
<p>I decided to post my <a href="http://www.xmonad.org/">XMonad</a> config file, since the web is so great as a backup engine <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Perhaps someone will find it useful:</p>
<p><a title="my XMonad config on hpaste.com" href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=7810#a7810">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=7810#a7810</a></p>
<p>It should be also accompanied with configuration for <a href="http://code.haskell.org/~arossato/xmobar/">xmobar</a>. I currently use two instances of xmobar, one for each of the screens. Their configuration is very similar. The only thing they differ in is position and size. Here is the <a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=7820#a7820">left one</a>.</p>
<br /> Tagged: config, hpaste, xmonad <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=38&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/09/04/current-xmonad-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
		<item>
		<title>Opera &#8211; RSS only?</title>
		<link>http://mostlycode.wordpress.com/2009/08/28/opera-rss-only/</link>
		<comments>http://mostlycode.wordpress.com/2009/08/28/opera-rss-only/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 00:43:21 +0000</pubDate>
		<dc:creator>Tener</dc:creator>
				<category><![CDATA[web utils]]></category>
		<category><![CDATA[firefox plugins]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://mostlycode.wordpress.com/?p=34</guid>
		<description><![CDATA[I was evaluating beta version of Opera lately. It was quite fun, but in the end there were just to many small annoyances to keep it going. Perhaps I&#8217;ll write a review in the future. In the meantime, I still use it as a RSS reader. It&#8217;s quite good at it, but perhaps someone knows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=34&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was evaluating beta version of Opera lately. It was quite fun, but in the end there were just to many small annoyances to keep it going. Perhaps I&#8217;ll write a review in the future. In the meantime, I still use it as a RSS reader. It&#8217;s quite good at it, but perhaps someone knows a <strong>better</strong> app/firefox plugin for that?</p>
<br /> Tagged: firefox plugins, opera, rss <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mostlycode.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mostlycode.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mostlycode.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mostlycode.wordpress.com&amp;blog=8817854&amp;post=34&amp;subd=mostlycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mostlycode.wordpress.com/2009/08/28/opera-rss-only/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7debf1d744f199ef1c9d9cb97a28243?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tener</media:title>
		</media:content>
	</item>
	</channel>
</rss>
