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

<channel>
	<title>Coder-Studio &#187; Alp Mestan</title>
	<atom:link href="http://www.coder-studio.com/blog/author/alp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coder-studio.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 02 Mar 2011 22:17:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>(Petit) Clône de client telnet en Haskell</title>
		<link>http://www.coder-studio.com/blog/petit-clone-de-client-telnet-en-haskell/</link>
		<comments>http://www.coder-studio.com/blog/petit-clone-de-client-telnet-en-haskell/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 11:19:08 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[fonctionnel]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=421</guid>
		<description><![CDATA[Bonjour, L'autre nuit, muni de café, j'ai souhaité m'amuser avec Haskell. J'ai alors consulté le chapitre sur le réseau en Haskell de Real World Haskell et... j'ai écrit un (très petit) clône de client telnet... qui fait 41 lignes. Le seul soucis étant que dans toute application de ce genre, on doit partager habilement la [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>L'autre nuit, muni de café, j'ai souhaité m'amuser avec Haskell. J'ai alors consulté le chapitre sur le réseau en Haskell de <a href="http://book.realworldhaskell.org/read/">Real World Haskell</a> et... j'ai écrit un (très petit) clône de client telnet... qui fait 41 lignes. Le seul soucis étant que dans toute application de ce genre, on doit partager habilement la lecture des entrées de l'utilisateur, et l'affichage de ce que l'on nous envoie. Ceci mis à part, tout cela fonctionne très bien !</p>
<p><center><img src="http://haskell.org/logos/logos/logo7000.png" alt="Haskell" title="Haskell" /></center></p>
<p><span id="more-421"></span></p>
<p>Regardons à quoi cela ressemble. Petit détail : à chaque tour, je lance la réception de données réseau dans un autre thread, pour ne pas bloquer l'écriture de l'utilisateur.</p>
<p>On importe d'abord les modules nécessaires.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code8'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4218"><td class="code" id="p421code8"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span>Concurrent 
<span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Monad"><span style="color: #cccc00; font-weight: bold;">Monad</span></a> 
<span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>Socket 
<span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>BSD 
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span>Environment 
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a></pre></td></tr></table></div>

<p>Ensuite, j'ai écrit quelques fonctions pour rendre la connection, l'envoi etc plus faciles.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code9'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4219"><td class="code" id="p421code9"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- Ouverture d'une connexion TCP cliente </span>
<span style="color: #5d478b; font-style: italic;">-- Prend en argument l'host et le port/service (qui est une String également) </span>
<span style="color: #5d478b; font-style: italic;">-- Retourne le &quot;Handle&quot; vers le socket en question. </span>
openConnection <span style="color: #339933; font-weight: bold;">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> <span style="color: #339933; font-weight: bold;">-&gt;</span> ServiceName <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> Handle 
openConnection hostname port <span style="color: #339933; font-weight: bold;">=</span> 
  <span style="color: #06c; font-weight: bold;">do</span> 
  addrInfos <span style="color: #339933; font-weight: bold;">&lt;-</span> getAddrInfo Nothing <span style="color: green;">&#40;</span>Just hostname<span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span>Just port<span style="color: green;">&#41;</span> 
  <span style="color: #06c; font-weight: bold;">let</span> serveraddr <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span style="font-weight: bold;">head</span></a> addrInfos 
  sock <span style="color: #339933; font-weight: bold;">&lt;-</span> socket <span style="color: green;">&#40;</span>addrFamily serveraddr<span style="color: green;">&#41;</span> Stream defaultProtocol 
  setSocketOption sock KeepAlive <span style="color: red;">1</span> 
  connect sock <span style="color: green;">&#40;</span>addrAddress serveraddr<span style="color: green;">&#41;</span> 
  h <span style="color: #339933; font-weight: bold;">&lt;-</span> socketToHandle sock ReadWriteMode 
  hSetBuffering h <span style="color: green;">&#40;</span>BlockBuffering Nothing<span style="color: green;">&#41;</span> 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return"><span style="font-weight: bold;">return</span></a> h 
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- Ferme la connexion dont le Handle est donné </span>
closeConnection <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span> 
closeConnection h <span style="color: #339933; font-weight: bold;">=</span> hClose h 
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- Envoie la chaîne donnée sur le Handle donné, et ensuite fait un flush sur ce handle, ce qui force l'envoi immédiat et nettoie les états </span>
sendMsg <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span> 
sendMsg h msg <span style="color: #339933; font-weight: bold;">=</span> hPutStrLn h msg <span style="color: #339933; font-weight: bold;">&gt;&gt;</span> hFlush h 
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- Lis sur le Handle donné une chaîne et la renvoie (dans la monade IO) </span>
recvMsg <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> 
recvMsg h <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  msg <span style="color: #339933; font-weight: bold;">&lt;-</span> hGetContents h  
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return"><span style="font-weight: bold;">return</span></a> msg</pre></td></tr></table></div>

<p>Voyons maintenant la fonction main.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code10'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42110"><td class="code" id="p421code10"><pre class="haskell" style="font-family:monospace;">main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  args <span style="color: #339933; font-weight: bold;">&lt;-</span> getArgs 
  <span style="color: #06c; font-weight: bold;">let</span> <span style="color: green;">&#40;</span>host<span style="color: #339933; font-weight: bold;">,</span> port<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span>args <span style="color: #339933; font-weight: bold;">!!</span> <span style="color: red;">0</span><span style="color: #339933; font-weight: bold;">,</span> args <span style="color: #339933; font-weight: bold;">!!</span> <span style="color: red;">1</span><span style="color: green;">&#41;</span></pre></td></tr></table></div>

<p>On récupère les arguments donnés au programme (s'il n'y en a pas assez, cela fera planter le logiciel -- je ne me suis pas vraiment préoccupé de tous les cas d'erreur, mais ce n'était pas ma priorité ici) via la fonction getArgs, et l'on en récupère l'host et le port donnés.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code11'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42111"><td class="code" id="p421code11"><pre class="haskell" style="font-family:monospace;">  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="color: #339933; font-weight: bold;">$</span> <span style="background-color: #3cb371;">&quot;Opening client on &quot;</span> <span style="color: #339933; font-weight: bold;">++</span> host <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;:&quot;</span> <span style="color: #339933; font-weight: bold;">++</span> port <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;<span style="background-color: #3cb371; font-weight: bold;">\n</span>&quot;</span> 
  hclient <span style="color: #339933; font-weight: bold;">&lt;-</span> openConnection host port 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;Client connected&quot;</span></pre></td></tr></table></div>

<p>Ca y est, on se connecte, en affichant des messages pour tenir l'utilisateur informé. Si la connection échoue, le programme s'arrêtera avec une erreur -- cf remarque ci-dessus.</p>
<p>Et maintenant, la boucle qui permet de lire depuis le réseau et lire depuis l'utilisateur, etc.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code12'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42112"><td class="code" id="p421code12"><pre class="haskell" style="font-family:monospace;">  forever <span style="color: #339933; font-weight: bold;">$</span> <span style="color: #06c; font-weight: bold;">do</span> 
    <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:getLine"><span style="font-weight: bold;">getLine</span></a> <span style="color: #339933; font-weight: bold;">&gt;&gt;=</span> sendMsg hclient 
    forkIO <span style="color: #339933; font-weight: bold;">$</span> recvMsg hclient <span style="color: #339933; font-weight: bold;">&gt;&gt;=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a></pre></td></tr></table></div>

<p>Ici, on a une sorte de boucle "à la while(true)", dans laquelle on va tour à tour récupérer une entrée de l'utilisateur et l'envoyer au serveur, puis, dans un thread séparé, récupérer ce qu'a envoyé le serveur et l'afficher.<br />
Enfin, on ferme la connection (ce code est inutile tant que l'on a pas de possibilité de sortir du forever... qui devra tôt ou tard se transformer en "until" ou autre).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code13'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42113"><td class="code" id="p421code13"><pre class="haskell" style="font-family:monospace;">  closeConnection hclient</pre></td></tr></table></div>

<p>Voilà le code complet :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p421code14'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p42114"><td class="code" id="p421code14"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span>Concurrent 
<span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Monad"><span style="color: #cccc00; font-weight: bold;">Monad</span></a> 
<span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>Socket 
<span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>BSD 
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span>Environment 
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> 
&nbsp;
openConnection <span style="color: #339933; font-weight: bold;">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> <span style="color: #339933; font-weight: bold;">-&gt;</span> ServiceName <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> Handle 
openConnection hostname port <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  addrInfos <span style="color: #339933; font-weight: bold;">&lt;-</span> getAddrInfo Nothing <span style="color: green;">&#40;</span>Just hostname<span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span>Just port<span style="color: green;">&#41;</span> 
  <span style="color: #06c; font-weight: bold;">let</span> serveraddr <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span style="font-weight: bold;">head</span></a> addrInfos 
  sock <span style="color: #339933; font-weight: bold;">&lt;-</span> socket <span style="color: green;">&#40;</span>addrFamily serveraddr<span style="color: green;">&#41;</span> Stream defaultProtocol 
  setSocketOption sock KeepAlive <span style="color: red;">1</span> 
  connect sock <span style="color: green;">&#40;</span>addrAddress serveraddr<span style="color: green;">&#41;</span> 
  h <span style="color: #339933; font-weight: bold;">&lt;-</span> socketToHandle sock ReadWriteMode 
  hSetBuffering h <span style="color: green;">&#40;</span>BlockBuffering Nothing<span style="color: green;">&#41;</span> 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return"><span style="font-weight: bold;">return</span></a> h 
&nbsp;
closeConnection <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span> 
closeConnection h <span style="color: #339933; font-weight: bold;">=</span> hClose h 
&nbsp;
sendMsg <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span> 
sendMsg h msg <span style="color: #339933; font-weight: bold;">=</span> hPutStrLn h msg <span style="color: #339933; font-weight: bold;">&gt;&gt;</span> hFlush h 
&nbsp;
recvMsg <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a> 
recvMsg h <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  msg <span style="color: #339933; font-weight: bold;">&lt;-</span> hGetContents h  
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return"><span style="font-weight: bold;">return</span></a> msg 
&nbsp;
main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  args <span style="color: #339933; font-weight: bold;">&lt;-</span> getArgs 
  <span style="color: #06c; font-weight: bold;">let</span> <span style="color: green;">&#40;</span>host<span style="color: #339933; font-weight: bold;">,</span> port<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span>args <span style="color: #339933; font-weight: bold;">!!</span> <span style="color: red;">0</span><span style="color: #339933; font-weight: bold;">,</span> args <span style="color: #339933; font-weight: bold;">!!</span> <span style="color: red;">1</span><span style="color: green;">&#41;</span> 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="color: #339933; font-weight: bold;">$</span> <span style="background-color: #3cb371;">&quot;Opening client on &quot;</span> <span style="color: #339933; font-weight: bold;">++</span> host <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;:&quot;</span> <span style="color: #339933; font-weight: bold;">++</span> port <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;<span style="background-color: #3cb371; font-weight: bold;">\n</span>&quot;</span> 
  hclient <span style="color: #339933; font-weight: bold;">&lt;-</span> openConnection host port 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;Client connected&quot;</span> 
  forever <span style="color: #339933; font-weight: bold;">$</span> <span style="color: #06c; font-weight: bold;">do</span> 
    <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:getLine"><span style="font-weight: bold;">getLine</span></a> <span style="color: #339933; font-weight: bold;">&gt;&gt;=</span> sendMsg hclient 
    forkIO <span style="color: #339933; font-weight: bold;">$</span> recvMsg hclient <span style="color: #339933; font-weight: bold;">&gt;&gt;=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> 
  closeConnection hclient</pre></td></tr></table></div>

<p>Compilation :</p>
<blockquote><p>ghc --make -o net net.hs</p></blockquote>
<p>Puis 2 exemples d'exécution...<br />
<code>
<pre>
$ ./net google.fr 80
Opening client on google.fr:80
Client connected
GET / HTTP/1.0
HTTP/1.0 302 Found
Location: http://www.google.fr/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=30b094ad566b5532:TM=1251456529:LM=1251456529:S=94IXp5-SGiaYADWc; expires=Sun, 28-Aug-2011 10:48:49 GMT; path=/; domain=.google.com
Date: Fri, 28 Aug 2009 10:48:49 GMT
Server: gws
Content-Length: 218 

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.fr/">here</A>.
</BODY></HTML> 

^C
</pre>
<p></code><br />
(c'est moi qui ai tapé "GET / HTTP/1.0")<br />
( qui vous dira que la page a été déplacée <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p>Et enfin, la surprise...</p>
<blockquote><p>$ ./net towel.blinkenlights.nl 23</p></blockquote>
<p>Qui, une version simplifiée d'un film très connu, vous permettra de voir, Jedi.</p>
<p>Enjoy !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/petit-clone-de-client-telnet-en-haskell/feed/</wfw:commentRss>
		<slash:comments>3006</slash:comments>
		</item>
		<item>
		<title>Haskell Platform, ou comment se mettre à Haskell sans soucis !</title>
		<link>http://www.coder-studio.com/blog/haskell-platform-ou-comment-se-mettre-a-haskell-sans-soucis/</link>
		<comments>http://www.coder-studio.com/blog/haskell-platform-ou-comment-se-mettre-a-haskell-sans-soucis/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 08:19:14 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[platform]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=401</guid>
		<description><![CDATA[Bonjour à tous, Cela fait quelques temps maintenant que la communauté Haskell a sorti Haskell Platform. Il s'agit d'un "paquet" qui regroupe : - le compilateur haskell GHC, un debugger, un profiler, etc - les bibliothèques les plus populaires et les plus utilisées, fournies d'office - tout un tas d'outils auxiliaires, comme haddock, qui permet [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour à tous,</p>
<p>Cela fait quelques temps maintenant que la communauté <a href="http://www.haskell.org/">Haskell</a> a sorti <strong><a href="http://hackage.haskell.org/platform/">Haskell Platform</a></strong>. Il s'agit d'un "paquet" qui regroupe :<br />
- le compilateur haskell GHC, un debugger, un profiler, etc<br />
- les bibliothèques les plus populaires et les plus utilisées, fournies d'office<br />
- tout un tas d'outils auxiliaires, comme <em>haddock</em>, qui permet de générer de la documentation depuis les commentaires du code source.</p>
<p>Il existe des paquets pour déjà quelques distributions Linux, sachant que ce sera bientôt prêt pour Debian et Ubuntu également. Les installeurs Windows et Mac sont très simples également.</p>
<p>Bref, plus aucune raison de ne pas essayer Haskell <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/haskell-platform-ou-comment-se-mettre-a-haskell-sans-soucis/feed/</wfw:commentRss>
		<slash:comments>3127</slash:comments>
		</item>
		<item>
		<title>GTK+ en Haskell</title>
		<link>http://www.coder-studio.com/blog/gtk-en-haskell/</link>
		<comments>http://www.coder-studio.com/blog/gtk-en-haskell/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 02:37:15 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[glade]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=342</guid>
		<description><![CDATA[Bonjour, M'étant mis à Haskell depuis quelques temps (principalement grâce au désormais fameux Real World Haskell), je me suis dis qu'il était temps que je regarde un peu du côté des bibliothèques pour interfaces utilisateurs. Hé bien, je n'ai pas été déçu. Il y a notamment Gtk2Hs qui fournit un bon binding de GTK+, compatible [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>M'étant mis à Haskell depuis quelques temps (principalement grâce au désormais fameux <a href="http://general.developpez.com/livres/general/?page=prog-fonctionnelle#L9780596514983">Real World Haskell</a>), je me suis dis qu'il était temps que je regarde un peu du côté des bibliothèques pour interfaces utilisateurs. Hé bien, je n'ai pas été déçu. Il y a notamment <strong>Gtk2Hs</strong> qui fournit un bon binding de GTK+, compatible avec Glade (le designer) et qui permet donc de charger des interfaces depuis du XML.</p>
<p><center><img src="http://blog.developpez.com/media/gtk2hs.png" width="409" height="297" alt="Gtk2Hs en action" /></center></p>
<p><span id="more-342"></span></p>
<p>Allez-y, devinez combien de lignes il a fallu ?<br />
Initialiser le GUI, créer les widgets, ... Hmm beaucoup ?</p>
<p>Hé bien non ! Le designer, Glade, exporte le "projet" suivant dans un XML.</p>
<p><center><img src="http://blog.developpez.com/media/glade.png" width="700" height="370" alt="Designer de fenêtres de GTK+" /></center></p>
<p>XML généré :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p342code17'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34217"><td class="code" id="p342code17"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;glade-interface<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #808080; font-style: italic;">&lt;!-- interface-requires gtk+ 2.16 --&gt;</span> 
  <span style="color: #808080; font-style: italic;">&lt;!-- interface-naming-policy project-wide --&gt;</span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;widget</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;GtkWindow&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;window1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;title&quot;</span> <span style="color: #000066;">translatable</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Hello, Developpez !<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;default_width&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>400<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;default_height&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>400<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;widget</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;GtkButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;yo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;label&quot;</span> <span style="color: #000066;">translatable</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Bonjour Developpez, comment vas-tu ? 
&nbsp;
Je suis un programme Haskell qui utilise 
Gtk2Hs, binding Haskell de GTK+. 
&nbsp;
Clique pour fermer.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;visible&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>True<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;can_focus&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>True<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;receives_default&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>True<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/widget<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/widget<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/glade-interface<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Et voilà, l'essentiel est fait.</p>
<p>Voici donc le main.hs, qui est le programme Haskell dont vous avez vu un screenshot plus haut :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p342code18'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34218"><td class="code" id="p342code18"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">module</span> Main <span style="color: #06c; font-weight: bold;">where</span> 
&nbsp;
<span style="color: #06c; font-weight: bold;">import</span> Graphics<span style="color: #339933; font-weight: bold;">.</span>UI<span style="color: #339933; font-weight: bold;">.</span>Gtk <span style="color: #5d478b; font-style: italic;">-- on importe le module GTK </span>
<span style="color: #06c; font-weight: bold;">import</span> Graphics<span style="color: #339933; font-weight: bold;">.</span>UI<span style="color: #339933; font-weight: bold;">.</span>Gtk<span style="color: #339933; font-weight: bold;">.</span>Glade <span style="color: #5d478b; font-style: italic;">-- et le module Glade, pour créer une IHM depuis le XML au format Glade </span>
&nbsp;
main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span> 
  initGUI 
  Just xml <span style="color: #339933; font-weight: bold;">&lt;-</span> xmlNew <span style="background-color: #3cb371;">&quot;test.glade&quot;</span>  
  window <span style="color: #339933; font-weight: bold;">&lt;-</span> xmlGetWidget xml castToWindow <span style="background-color: #3cb371;">&quot;window1&quot;</span> 
  button <span style="color: #339933; font-weight: bold;">&lt;-</span> xmlGetWidget xml castToButton <span style="background-color: #3cb371;">&quot;yo&quot;</span> 
  onClicked button <span style="color: #339933; font-weight: bold;">$</span> <span style="color: #06c; font-weight: bold;">do</span> 
  <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;Bye&quot;</span> 
  mainQuit 
  onDestroy window mainQuit 
  widgetShowAll window 
  mainGUI</pre></td></tr></table></div>

<p>Et voilà. Assez simple non ? <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/gtk-en-haskell/feed/</wfw:commentRss>
		<slash:comments>3022</slash:comments>
		</item>
		<item>
		<title>Récupération et parsing d&#039;un flux Atom XML en Haskell</title>
		<link>http://www.coder-studio.com/blog/recuperation-et-parsing-dun-flux-atom-xml-en-haskell/</link>
		<comments>http://www.coder-studio.com/blog/recuperation-et-parsing-dun-flux-atom-xml-en-haskell/#comments</comments>
		<pubDate>Mon, 04 May 2009 20:27:26 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=301</guid>
		<description><![CDATA[Bonsoir, Il y a peu, on m'a demandé d'écrire un programme qui récupère un flux Atom XML et qui ne récupère que le titre et l'url des éléments (qui en l'occurence sont des billets aggrégés sur Planet OCaml). J'ai hésité entre OCaml, C++ et Haskell. Plutôt tenté par du fonctionnel, mon choix s'est vite porté [...]]]></description>
			<content:encoded><![CDATA[<p>Bonsoir,</p>
<p>Il y a peu, on m'a demandé d'écrire un programme qui récupère un flux Atom XML et qui ne récupère que le titre et l'url des éléments (qui en l'occurence sont des billets aggrégés sur <a href="http://planet.ocamlcore.org/">Planet OCaml</a>).</p>
<p>J'ai hésité entre OCaml, C++ et Haskell. Plutôt tenté par du fonctionnel, mon choix s'est vite porté sur Haskell grâce au nombre impressionnant de paquets présents sur Hackage.<br />
J'ai donc opté pour le paquet <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed-0.3.6">feed</a> pour la gestion d'Atom et <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/download">download</a> pour la récupération du XML distant, qui se situe <a href="http://planet.ocamlcore.org/atom.xml">ici</a>).</p>
<div class="wp-caption aligncenter" style="width: 70px"><img alt="Haskell Logo" src="http://haskell.org/sitewiki/images/a/a8/Haskell-logo-60.png" title="Haskell Logo" width="60" height="43" /><p class="wp-caption-text">Haskell Logo</p></div>
<p><span id="more-301"></span></p>
<p>Alors, voyons voir... Premièrement, on importe les modules dont on a besoin, évidemment.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code29'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30129"><td class="code" id="p301code29"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>Download
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Atom<span style="color: #339933; font-weight: bold;">.</span>Feed
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Feed<span style="color: #339933; font-weight: bold;">.</span>Import
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Feed<span style="color: #339933; font-weight: bold;">.</span>Types</pre></td></tr></table></div>

<p>Ensuite, on définit l'adresse du fichier atom.xml... Toujours rien de bien sorcier.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code30'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30130"><td class="code" id="p301code30"><pre class="haskell" style="font-family:monospace;">url <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;http://planet.ocamlcore.org/atom.xml&quot;</span></pre></td></tr></table></div>

<p>Puis on se lance dans main !</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code31'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30131"><td class="code" id="p301code31"><pre class="haskell" style="font-family:monospace;">main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span>
    <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;*** Recent blog posts ***&quot;</span>
    Right src <span style="color: #339933; font-weight: bold;">&lt;-</span> openURIString url</pre></td></tr></table></div>

<p>Ici, on affiche simplement un message dans la console, puis on récupère le contenu du fichier dans la chaîne de caractères <em>src</em>.<br />
<strong>Right</strong> est l'un des constructeurs du type <a href="http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Data-Either.html#t%3AEither"><strong>Either</strong></a>, ne vous en préoccupez pas trop.</p>
<p>Ensuite, on s'occupe à proprement parler du flux Atom...</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code32'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30132"><td class="code" id="p301code32"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> Just <span style="color: green;">&#40;</span>AtomFeed is<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> parseFeedString src</pre></td></tr></table></div>

<p><strong>Just</strong> est un constructeur du type <a href="http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Data-Maybe.html#t%3AMaybe"><strong>Maybe</strong></a>, qui permet de gérer les erreurs (Just mavaleur si pas eu d'erreur, Nothing si une erreur). AtomFeed est lui un constructeur pour le type <a href="http://hackage.haskell.org/packages/archive/feed/0.3.6/doc/html/Text-Feed-Types.html#t%3AFeed"><strong>Feed</strong></a> précisant que c'est un flux Atom, et non RSS1 ou RSS2 par exemple (qui sont eux aussi gérés par ce même paquet). La fonction <em>parseFeedString</em> prend donc une chaîne (ici <em>src</em>) et retourne un flux Atom... C'est là, en utilisant <em>is</em>, que l'on va pouvoir récupérer les différents éléments du XML au format Atom.</p>
<p>Bon, et si on récupérait les différentes entrées de notre flux (ici ce sont des billets de blog) ?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code33'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30133"><td class="code" id="p301code33"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> entries <span style="color: #339933; font-weight: bold;">=</span> feedEntries is</pre></td></tr></table></div>

<p>Ceci nous retourne donc une liste d'<a href="http://hackage.haskell.org/packages/archive/feed/0.3.6/doc/html/Text-Atom-Feed.html#t%3AEntry"><strong>Entry</strong></a>. Et c'est parti, on va récupérer les informations qu'il nous faut, puis les afficher !</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code34'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30134"><td class="code" id="p301code34"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> infos <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span style="font-weight: bold;">map</span></a> <span style="color: green;">&#40;</span>\e <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#40;</span>entryTitle e<span style="color: #339933; font-weight: bold;">,</span> entryId e<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> entries
<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:mapM_"><span style="font-weight: bold;">mapM_</span></a> <span style="color: green;">&#40;</span>\<span style="color: green;">&#40;</span>x<span style="color: #339933; font-weight: bold;">,</span>y<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="color: #339933; font-weight: bold;">$</span> <span style="color: green;">&#40;</span>stringize x<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;: &quot;</span> <span style="color: #339933; font-weight: bold;">++</span> y<span style="color: green;">&#41;</span> infos</pre></td></tr></table></div>

<p>Oui, oui, ça se complique un peu.<br />
Tout d'abord, qu'est-ce que <em>infos</em> ? <em>map</em> transforme chaque élément en l'image de l'élément donné par son premier argument, qui est donc une fonction. Ici, on va transformer chaque <strong>Entry</strong> en un couple <em>(titre, id)</em> associé à notre entrée, où id se trouve être l'URL originale du billet.<br />
Bon infos est donc la liste des couples (titre, url). Ah ? Ce n'étant pas tellement cette ligne qui vous faisait peur mais la suivante ?<br />
Bon, sans rentrer en détail dans les monades (<a href="http://haskell.org/haskellwiki/Monad">la page Monad du HaskellWiki</a> le faisant mieux que moi, et surtout donnant d'excellents liens pour comprendre de quoi il s'agit, où c'est utilisé, etc), on se trouve dans la monade IO. mapM_ se retrouve donc avec le type :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code35'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30135"><td class="code" id="p301code35"><pre class="haskell" style="font-family:monospace;"><span style="color: green;">&#40;</span>a <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> b<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#91;</span>a<span style="color: green;">&#93;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span></pre></td></tr></table></div>

<p>Notre <em>[a]</em>, c'est infos, donc notre liste de couples...<br />
<em>(a -> IO b)</em> est effectivement le type de notre fonction anonyme, que je me permets de vous montrer à part ici :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code36'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30136"><td class="code" id="p301code36"><pre class="haskell" style="font-family:monospace;">\<span style="color: green;">&#40;</span>x<span style="color: #339933; font-weight: bold;">,</span>y<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="color: #339933; font-weight: bold;">$</span> <span style="color: green;">&#40;</span>stringize x<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;: &quot;</span> <span style="color: #339933; font-weight: bold;">++</span> y</pre></td></tr></table></div>

<p>A un couple (titre,url), elle associe un appel à <em>putStrLn</em>, qui retourne <em>IO ()</em>. Donc le type <em>b</em> est en fait <em>()</em>. <em>mapM_</em> ne faut qu'effectuer des actions dans une monade donnée, en ignorant le résultat de chacune au lieu de les placer des une liste comme le fait son homologue <em>mapM</em></p>
<p>Ah oui, j'oubliais, stringize, qui est définie juste après fonction main.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code37'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30137"><td class="code" id="p301code37"><pre class="haskell" style="font-family:monospace;">stringize <span style="color: #339933; font-weight: bold;">::</span> TextContent <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a>
stringize <span style="color: green;">&#40;</span>TextString s<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> s
stringize <span style="color: #339933; font-weight: bold;">_</span> <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error"><span style="font-weight: bold;">error</span></a> <span style="background-color: #3cb371;">&quot;shoud not be called on something else than TextString&quot;</span></pre></td></tr></table></div>

<p>Elle me permet juste de passer d'une valeur construite avec TextString, donc de type <a href="http://hackage.haskell.org/packages/archive/feed/0.3.6/doc/html/Text-Atom-Feed.html#t%3ATextContent"><strong>TextContent</strong></a>, à la valeur qui est en fait englobée par ce type, de type String.</p>
<p>Voilà donc le code complet :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p301code38'); return false;">View Code</a> HASKELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p30138"><td class="code" id="p301code38"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> Network<span style="color: #339933; font-weight: bold;">.</span>Download
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Atom<span style="color: #339933; font-weight: bold;">.</span>Feed
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Feed<span style="color: #339933; font-weight: bold;">.</span>Import
<span style="color: #06c; font-weight: bold;">import</span> Text<span style="color: #339933; font-weight: bold;">.</span>Feed<span style="color: #339933; font-weight: bold;">.</span>Types
&nbsp;
url <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;http://planet.ocamlcore.org/atom.xml&quot;</span>
&nbsp;
main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span>
    <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;*** Recent blog posts ***&quot;</span>
    Right src <span style="color: #339933; font-weight: bold;">&lt;-</span> openURIString url
    <span style="color: #06c; font-weight: bold;">let</span> Just <span style="color: green;">&#40;</span>AtomFeed is<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> parseFeedString src
    <span style="color: #06c; font-weight: bold;">let</span> entries <span style="color: #339933; font-weight: bold;">=</span> feedEntries is
    <span style="color: #06c; font-weight: bold;">let</span> infos <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span style="font-weight: bold;">map</span></a> <span style="color: green;">&#40;</span>\e <span style="color: #339933; font-weight: bold;">-&gt;</span> <span style="color: green;">&#40;</span>entryTitle e<span style="color: #339933; font-weight: bold;">,</span> entryId e<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> entries
    <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:mapM_"><span style="font-weight: bold;">mapM_</span></a> <span style="color: green;">&#40;</span>\<span style="color: green;">&#40;</span>x<span style="color: #339933; font-weight: bold;">,</span>y<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="color: #339933; font-weight: bold;">$</span> <span style="color: green;">&#40;</span>stringize x<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">++</span> <span style="background-color: #3cb371;">&quot;: &quot;</span> <span style="color: #339933; font-weight: bold;">++</span> y<span style="color: green;">&#41;</span> infos
&nbsp;
stringize <span style="color: #339933; font-weight: bold;">::</span> TextContent <span style="color: #339933; font-weight: bold;">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span style="color: #cccc00; font-weight: bold;">String</span></a>
stringize <span style="color: green;">&#40;</span>TextString s<span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">=</span> s
stringize <span style="color: #339933; font-weight: bold;">_</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;stringize Error&quot;</span></pre></td></tr></table></div>

<p>La compilation :</p>
<blockquote><p>$ ghc -package download -o cwn cwn.hs</p></blockquote>
<p>Et un exemple d'execution :</p>
<blockquote><p>$ ./cwn<br />
*** Recent blog posts ***<br />
ocaml-text: http://forge.ocamlcore.org/projects/ocaml-text/<br />
0.1.3 sources now in subversion: http://forge.ocamlcore.org/forum/forum.php?forum_id=355<br />
Sudoku in ocamljs, part 2: RPC over HTTP: tag:blogger.com,1999:blog-1445545651031573301.post-3490486535879812384<br />
Caml Weekly News, 28 Apr 2009: http://alan.petitepomme.net/cwn/2009.04.28.html<br />
Bouncing Ball in OCaml with OCamlSDL: http://blog.mestan.fr/?p=31<br />
Sudoku in ocamljs, part 1: DOM programming: tag:blogger.com,1999:blog-1445545651031573301.post-4574121943207730951<br />
Using OCaml’s module functors to provide monadic contexts for Batteries: http://blog.mestan.fr/?p=30<br />
Lastfm no longer free as in free beer (and some bits about xml in OCaml): http://blog.rastageeks.org/spip.php?article34<br />
Last lecture: http://dutherenverseauborddelatable.wordpress.com/?p=571<br />
Liquidsoap now supports AAC+ encoding.: http://blog.rastageeks.org/spip.php?article33</p></blockquote>
<p>Alors, pas si "académique" que ça le fonctionnel, non ? <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Tout ça en 18 lignes, lignes vides comprises, 15 non comprises.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/recuperation-et-parsing-dun-flux-atom-xml-en-haskell/feed/</wfw:commentRss>
		<slash:comments>3501</slash:comments>
		</item>
		<item>
		<title>OCaml et la 3D : CamlGL &amp; LablGL</title>
		<link>http://www.coder-studio.com/blog/276/</link>
		<comments>http://www.coder-studio.com/blog/276/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 15:50:35 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[GlCaml]]></category>
		<category><![CDATA[LablGl]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[ocamlsdl]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=276</guid>
		<description><![CDATA[Bonsoir, Comme demandé récemment par l'un des membres, il est tout à fait possible de faire de la 3D avec OpenGL en OCaml. Il y a principalement 2 bindings. LablGL GlCaml Inutile de commencer à donner un cours sur OpenGL, la plupart d'entre vous connaissant déjà, qui plus est il y a tout le nécessaire [...]]]></description>
			<content:encoded><![CDATA[<p>Bonsoir,</p>
<p>Comme demandé récemment par l'un des membres, il est tout à fait possible de faire de la 3D avec OpenGL en OCaml. Il y a principalement 2 bindings.</p>
<ul>
<li><a href="http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgl.html">LablGL</a></li>
<li><a href="http://glcaml.sourceforge.net/">GlCaml</a></li>
</ul>
<p><div id="attachment_277" class="wp-caption aligncenter" style="width: 657px"><a href="http://www.coder-studio.com/blog/wp-content/uploads/2009/04/glcaml.png"><img src="http://www.coder-studio.com/blog/wp-content/uploads/2009/04/glcaml.png" alt="Exemple d&#039;utilisation de GlCaml" title="glcaml" width="647" height="517" class="size-full wp-image-277" /></a><p class="wp-caption-text">Exemple d'utilisation de GlCaml</p></div><br />
Inutile de commencer à donner un cours sur OpenGL, la plupart d'entre vous connaissant déjà, qui plus est il y a tout le nécessaire pour OpenGL en C &#038; C++. Ces deux bibliothèques OCaml ne sont que des bindings, c'est à dire qu'elles appellent les fonctions C classiques en interfaçant par le biais de fonctions OCaml.</p>
<p>Juste pour vous donner une idée, voici un extrait du code correspondant au screenshot ci-dessus. Il s'agissait ici de montrer que ça existe, à quoi ça ressemble et où trouver le nécessaire pour s'y mettre.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p276code40'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p27640"><td class="code" id="p276code40"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> draw_gl_scene <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span>
    glClear  <span style="color: #6c6;">&#40;</span>gl_color_buffer_bit lor gl_depth_buffer_bit<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>		 <span style="color: #5d478b; font-style: italic;">(* Clear The Screen And The Depth Buffer *)</span>
    glLoadIdentity  <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>				 <span style="color: #5d478b; font-style: italic;">(* Reset The View*)</span>
&nbsp;
    glTranslatef <span style="color: #c6c;">0.0</span> <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">!</span>z <span style="color: #a52a2a;">;</span>                   <span style="color: #5d478b; font-style: italic;">(* move z units out from the screen. *)</span>
&nbsp;
    glRotatef <span style="color: #a52a2a;">!</span>xrot <span style="color: #c6c;">1.0</span> <span style="color: #c6c;">0.0</span> <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>		 <span style="color: #5d478b; font-style: italic;">(* Rotate On The X Axis *)</span>
    glRotatef <span style="color: #a52a2a;">!</span>yrot <span style="color: #c6c;">0.0</span> <span style="color: #c6c;">1.0</span> <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>		 <span style="color: #5d478b; font-style: italic;">(* Rotate On The Y Axis *)</span>
&nbsp;
    glBindTexture gl_texture_2d  texture<span style="color: #a52a2a;">.</span><span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">!</span>filter<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>    <span style="color: #5d478b; font-style: italic;">(* choose the texture to use. *)</span>
&nbsp;
    glBegin gl_quads <span style="color: #a52a2a;">;</span>		                 <span style="color: #5d478b; font-style: italic;">(* begin drawing a cube *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Front Face  note that the texture's corners have to match the quad's corners  *)</span>
    glNormal3f  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>                               <span style="color: #5d478b; font-style: italic;">(* front face points out of the screen on z. *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Back Face *)</span>
    glNormal3f  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>                               <span style="color: #5d478b; font-style: italic;">(* back face points into the screen on z. *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Top Face *)</span>
    glNormal3f  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>                               <span style="color: #5d478b; font-style: italic;">(* top face points up on y. *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Bottom Face   *)</span>     
    glNormal3f  <span style="color: #c6c;">0.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>                              <span style="color: #5d478b; font-style: italic;">(* bottom face points down on y.  *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Right face *)</span>
    glNormal3f  <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>                               <span style="color: #5d478b; font-style: italic;">(* right face points right on x. *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f  <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
&nbsp;
     <span style="color: #5d478b; font-style: italic;">(* Left Face *)</span>
    glNormal3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span>                               <span style="color: #5d478b; font-style: italic;">(* left face points left on x. *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Left Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Bottom Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">1.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>   <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Right Of The Texture and Quad *)</span>
    glTexCoord2f <span style="color: #c6c;">0.0</span>  <span style="color: #c6c;">1.0</span> <span style="color: #a52a2a;">;</span> glVertex3f <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span>   <span style="color: #c6c;">1.0</span>  <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">-.</span>1<span style="color: #a52a2a;">.</span>0<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;</span>	 <span style="color: #5d478b; font-style: italic;">(* Top Left Of The Texture and Quad *)</span>
&nbsp;
    glEnd  <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>                                     <span style="color: #5d478b; font-style: italic;">(* done with the polygon. *)</span>
&nbsp;
    xrot <span style="color: #a52a2a;">:=</span> <span style="color: #a52a2a;">!</span>xrot <span style="color: #a52a2a;">+.</span> <span style="color: #a52a2a;">!</span>xspeed<span style="color: #a52a2a;">;</span>		                 <span style="color: #5d478b; font-style: italic;">(* X Axis Rotation	 *)</span>
    yrot <span style="color: #a52a2a;">:=</span> <span style="color: #a52a2a;">!</span>yrot <span style="color: #a52a2a;">+.</span> <span style="color: #a52a2a;">!</span>yspeed		                 <span style="color: #5d478b; font-style: italic;">(* Y Axis Rotation *)</span></pre></td></tr></table></div>

<p>PS : aucun des deux ne semble être encore maintenu, toutefois GlCaml prend en charge les versions d'OpenGL jusqu'à 2.1 + extensions ARB et spécifiques aux vendeurs. GlCaml embarque un binding minimal de la SDL, moins complet que OCamlSDL que j'ai présenté dans un post précédent.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/276/feed/</wfw:commentRss>
		<slash:comments>5107</slash:comments>
		</item>
		<item>
		<title>Bouncing Ball en OCaml avec OCamlSDL</title>
		<link>http://www.coder-studio.com/blog/bouncing-ball-en-ocaml-avec-ocamlsdl/</link>
		<comments>http://www.coder-studio.com/blog/bouncing-ball-en-ocaml-avec-ocamlsdl/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 23:26:17 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[bouncing ball]]></category>
		<category><![CDATA[fonctionnel]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[ocamlsdl]]></category>
		<category><![CDATA[programmation fonctionnelle]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=271</guid>
		<description><![CDATA[Bonsoir, J'ai écrit un petit programme OCaml de Boucing Ball, une balle qui rebondit contre les bords de la fenêtre, où l'on peut augmenter la vitesse en X et en Y avec les touches du clavier. Il utilise OCamlSDL, un binding de la désormais célèbre bibliothèque SDL pour le langage OCaml. Voici ce que cela [...]]]></description>
			<content:encoded><![CDATA[<p>Bonsoir,</p>
<p>J'ai écrit un petit programme OCaml de Boucing Ball, une balle qui rebondit contre les bords de la fenêtre, où l'on peut augmenter la vitesse en X et en Y avec les touches du clavier.<br />
Il utilise OCamlSDL, un binding de la désormais célèbre bibliothèque <a href="http://www.libsdl.org/">SDL</a> pour le langage OCaml.</p>
<p>Voici ce que cela donne.</p>
<p><center><div id="attachment_272" class="wp-caption alignnone" style="width: 410px"><a href="http://www.coder-studio.com/blog/wp-content/uploads/2009/04/bbsdl.png"><img src="http://www.coder-studio.com/blog/wp-content/uploads/2009/04/bbsdl.png" alt="Boucing Ball en action" title="bbsdl" width="400" height="316" class="size-full wp-image-272" /></a><p class="wp-caption-text">Boucing Ball en action</p></div></center></p>
<p>Si vous voulez tester et/ou améliorer ce programme, qui peut soit dit en passant servir de base pour un Pong ou autre jeu de ce genre, vous trouverez le code source ici : <a href="http://mestan.fr/ocaml/bbsdl/bbsdl.tar.gz">bbsdl.tar.gz</a>.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/bouncing-ball-en-ocaml-avec-ocamlsdl/feed/</wfw:commentRss>
		<slash:comments>2039</slash:comments>
		</item>
		<item>
		<title>La programmation fonctionnelle n&#039;est pas un jouet pour académiciens</title>
		<link>http://www.coder-studio.com/blog/la-programmation-fonctionnelle-nest-pas-un-jouet-pour-academiciens/</link>
		<comments>http://www.coder-studio.com/blog/la-programmation-fonctionnelle-nest-pas-un-jouet-pour-academiciens/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 18:30:26 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[programmation fonctionnelle]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=267</guid>
		<description><![CDATA[Bonjour, Cela fait maintenant un moment que j'apprends et pratique la programmation fonctionnelle, aussi bien sur le point de vue théorique en m'intéressant à ses relations avec la théorie des catégories (mathématiques) entre autres, que sur le point de vue pratique, c'est à dire que j'ai mené quelques projets (de petite envergure... oui, c'est proportionnel [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Cela fait maintenant un moment que j'apprends et pratique la programmation fonctionnelle, aussi bien sur le point de vue théorique en m'intéressant à ses relations avec la théorie des catégories (mathématiques) entre autres, que sur le point de vue pratique, c'est à dire que j'ai mené quelques projets (de petite envergure... oui, c'est proportionnel au temps que je peux passer dessus) à bien.</p>
<p>Quand on dit "langage fonctionnel" ou "programmation fonctionnelle", les gens s'imaginent (pour ceux qui ne connaissent pas) des programmes avec tout un tas de fonctions, c'est tout. Ce n'est pas ça la programmation fonctionnelle. Enfin biensûr il y a des fonctions, mais la programmation fonctionnelle ne s'arrête pas là.</p>
<p>Déjà, la programmation fonctionnelle, c'est une toute autre façon de concevoir des programmes. Détailler toutes les différences avec la programmation impérative serait pire que les 12 travaux d'Hercules et c'est pourquoi je ne le ferai pas. Je vais toutefois vous parler des points qui font que je suis désormais adepte de ce style de programmation.</p>
<p><center><img src="http://www.geocities.com/EnchantedForest/1110/images/lambda.gif" alt="" title="La programmation fonctionnelle tire ses racines du lambda-calcul" /></center><br />
<span id="more-267"></span></p>
<p>Tout d'abord, étant assez orienté mathématiques, il y a une première chose qui me plaît. Dans les langages de programmation fonctionnelle (du moins la plupart), on définit des types, des opérations sur ces types, le tout très simplement et de manière on ne peut plus cohérente.</p>
<p>Ensuite, pour les langages fonctionnels compilés et typés statiquement, on est généralement accompagné d'un compilateur très strict, qui tentera d'éliminer un maximum d'incohérences (comprendre "erreurs") en nous envoyant des erreurs très précises en rapport avec le fait que nous n'avons pas bien typé des parties de notre programme. De plus, les 3 langages majeurs pour une utilisation "real world", Haskell, OCaml et F#, ont vu leur compilateur se doter de l'inférence de type ; il s'agit de la capacité qu'a un compilateur a donner lui-même un type à vos valeurs dans le programme (fonctions, expressions, ...). Entre ceci et la vérification des types, la compilation possède une part de travail autour des types en action dans votre code.</p>
<p>De plus, en programmation fonctionnelle, il s'agit de ne pas avoir ce que l'on appelle des effets de bords ; on parle de programmation fonctionnelle pure ; dans un tel cadre, une fonction à qui l'on donne les mêmes entrées renverra toujours la même sortie. Les programmeurs fonctionnels font en sorte d'isoler les parties pour lesquelles ce n'est pas vrai (lecture d'un fichier, intéraction réseau, ...) : monades en Haskell, on laisse la possibilité de faire de l'impératif pour OCaml et F#, ... </p>
<p>Continuons sur la curryfication. Cette dernière consiste à faire par exemple d'une fonction de 2 arguments 2 fonctions à 1 argument, qui pourront s'appliquer partiellement. Si l'on définit une fonction "add" pour ajouter 2 nombres x et y, alors on pourra appliquer add à son premier argument, x, en lui donnant par exemple la valeur 12, pour obtenir une fonction à UN SEUL argument qui additionnera son argument à 12.</p>
<p>Les fonctions sont capitales en programmation fonctionnelle. Contrairement à dans un certain nombre de langages (beaucoup), les fonctions peuvent être stockées, passées en argument, construites à la volée, retournées par d'autres fonctions, etc. Elles deviennent des valeurs de première classe. </p>
<p>A propos du passage en argument, une chose très importante en programmation fonctionnelle est la possibilité d'abstraire une partie des algorithmes et d'en confier la responsabilité à une fonction donnée en argument par exemple. Une fonction qui prend une autre fonction en argument est appelée "fonction d'ordre supérieur". Cela permet de factoriser un maximum de code tout en laissant la variabilité possible grâce au passage de fonction en argument. Le compilateur fera les vérifications nécessaires pour voir si les types concordent, ne vous inquiétez pas.</p>
<p>La paresse est également quelque chose qui s'avère bien sympathique parfois. Il s'agit de n'évaluer une expression qu'au moment où l'on en aura besoin (affichage du résultat de l'évaluation de l'expression -- comme une addition -- par exemple). Elle est mise en oeuvre différemment selon les langages (implicitement en Haskell, c'est le compilateur qui gère cela, alors que c'est explicit en OCaml -- module Lazy).</p>
<p>Tout cela, rajouté aux syntaxes assez simples, donne une très grande expressivité aux langages fonctionnels, proche de l'expressivité que l'on a en mathématiques. Qui plus est, rappelons-le, les langages fonctionnels sont des langages dits "déclaratifs". On exprime le problème, on obtient la solution, contrairement à ce que l'on fait dans un langage impératif où l'on doit donner toutes les étapes à la main nous-mêmes.</p>
<p>Bref, beaucoup d'avantages, un tout nouveau style de programmation, cela ne vaut-il pas le détour ? Allez, si vous voulez en savoir plus, voici quelques liens essentiels pour terminer ce billet sur la programmation fonctionnelle.<br />
<a href="http://damien-guichard.developpez.com/tutoriels/ocaml/">Cours d'introduction à OCaml de Damien Guichard</a> -- dont je me suis beaucoup servi et que j'apprécie beaucoup<br />
<a href="http://gorgonite.developpez.com/livres/traductions/haskell/gentle-haskell/">Traduction de "A gentle introduction to Haskell"</a> -- un peu rude pour débuter, mais vous fera comprendre pas mal de choses. </p>
<p>N'hésitez pas à utiliser le forum pour donner vos avis et retours d'expérience ou pour des questions, bien évidemment !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/la-programmation-fonctionnelle-nest-pas-un-jouet-pour-academiciens/feed/</wfw:commentRss>
		<slash:comments>1026</slash:comments>
		</item>
		<item>
		<title>Les sujets en rapport avec OCaml qui vous intéresseraient</title>
		<link>http://www.coder-studio.com/blog/les-sujets-en-rapport-avec-ocaml-qui-vous-interesseraient/</link>
		<comments>http://www.coder-studio.com/blog/les-sujets-en-rapport-avec-ocaml-qui-vous-interesseraient/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 18:18:18 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[ocaml]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=262</guid>
		<description><![CDATA[Salut, Étant tombé amoureux du langage OCaml, et comptant propulser cette activité de blog sur Coder-Studio, j'aimerais savoir ce que vous, amateur du langage OCaml, de la programmation fonctionnelle en général ou tout simplement curieux, vous souhaiteriez lire en rapport avec OCaml sur notre site préféré Alors ? Quelques grandes lignes qui pourraient intéresser : [...]]]></description>
			<content:encoded><![CDATA[<p><center>Salut,</center></p>
<p><center><img src="http://lampwww.epfl.ch/%7Emichelou/images/ocaml.gif" alt="" /></center></p>
<p>Étant tombé amoureux du langage OCaml, et comptant propulser cette activité de blog sur Coder-Studio, j'aimerais savoir ce que vous, amateur du langage OCaml, de la programmation fonctionnelle en général ou tout simplement curieux, vous souhaiteriez lire en rapport avec OCaml sur notre site préféré <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Alors ?<br />
Quelques grandes lignes qui pourraient intéresser :<br />
- OCaml et les maths (comme <a href="http://www.coder-studio.com/blog/construction-de-lensemble-de-cantor-en-ocaml/">mon billet précédent</a>)<br />
- OCaml et les GUIs<br />
- OCaml et le multimédia (OCamlSDL, OCaml/OpenGL, ...)<br />
- OCaml et la conception de compilateurs/interpréteurs (lexing, parsing, etc)<br />
- ...</p>
<p>Merci de donner votre avis !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/les-sujets-en-rapport-avec-ocaml-qui-vous-interesseraient/feed/</wfw:commentRss>
		<slash:comments>1759</slash:comments>
		</item>
		<item>
		<title>Construction de l&#039;Ensemble de Cantor en OCaml</title>
		<link>http://www.coder-studio.com/blog/construction-de-lensemble-de-cantor-en-ocaml/</link>
		<comments>http://www.coder-studio.com/blog/construction-de-lensemble-de-cantor-en-ocaml/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 23:12:36 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[batteries]]></category>
		<category><![CDATA[cantor]]></category>
		<category><![CDATA[included]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=235</guid>
		<description><![CDATA[Bonsoir, Un billet à propos d'OCaml, encore. Je me suis amusé à implémenter la construction de l'Ensemble de Cantor (version anglaise un peu plus complète). Vous voulez en savoir plus ? Première étape, il me fallait une fonction qui à partir d'une liste et d'un couple (a,b) de nombre réels, représentant l'intervalle [a,b], rajoute les [...]]]></description>
			<content:encoded><![CDATA[<p>Bonsoir,</p>
<p>Un billet à propos d'OCaml, encore. Je me suis amusé à implémenter la construction de <a href="http://fr.wikipedia.org/wiki/Ensemble_de_Cantor">l'Ensemble de Cantor</a> (<a href="http://en.wikipedia.org/wiki/Cantor_set">version anglaise un peu plus complète</a>). Vous voulez en savoir plus ?</p>
<p><center><a href="http://www.coder-studio.com/blog/construction-de-lensemble-de-cantor-en-ocaml/#more-235"><img src="http://www.developpez.net/forums/u67052-a100-i323.png" alt="Construction de l'Ensemble de Cantor" /></a><br />
<span id="more-235"></span></center></p>
<p>Première étape, il me fallait une fonction qui à partir d'une liste et d'un couple (a,b) de nombre réels, représentant l'intervalle [a,b], rajoute les deux intervalles qui en sont générés par une itéraction de la construction de l'ensemble de Cantor, c'est à dire les intervalles [a, (2a+b)/3] et [(a+2b)/3, b], à la liste. Voici la fonction en question, appelée cantor_step ici :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code47'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23547"><td class="code" id="p235code47"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> cantor_step l <span style="color: #6c6;">&#40;</span>a,b<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span>
 <span style="color: #6c6;">&#40;</span>a, <span style="color: #6c6;">&#40;</span>a <span style="color: #a52a2a;">+.</span> <span style="color: #060;">a</span> <span style="color: #a52a2a;">+.</span> <span style="color: #060;">b</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">/.</span> <span style="color: #c6c;">3</span><span style="color: #a52a2a;">.</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">::</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>a <span style="color: #a52a2a;">+.</span> <span style="color: #060;">b</span> <span style="color: #a52a2a;">+.</span> <span style="color: #060;">b</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">/.</span> <span style="color: #c6c;">3</span><span style="color: #a52a2a;">.</span>, b<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">::</span> l</pre></td></tr></table></div>

<p>Ensuite, il fallait une fonction qui permettre d'appliquer cette fonction sur une liste de couples (a,b) pour passer d'une liste d'intervalles à une autre, c'est à dire passer à l'étape suivante de la génération de l'Ensemble de Cantor. J'ai par la même occasion profité pour rajouté un paramètre n permettant de réaliser cela n fois. J'ai appelé cette fonction map_n.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code48'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23548"><td class="code" id="p235code48"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> map_n f l n <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">match</span> l <span style="color: #06c; font-weight: bold;">with</span>
  <span style="color: #a52a2a;">|</span> <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span> <span style="color: #a52a2a;">-&gt;</span> <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span>
  <span style="color: #a52a2a;">|</span> l <span style="color: #a52a2a;">-&gt;</span> aux l n 
      where
	<span style="color: #06c; font-weight: bold;">rec</span> aux l <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">function</span> 
	  <span style="color: #a52a2a;">|</span> <span style="color: #c6c;">0</span> <span style="color: #a52a2a;">-&gt;</span> l
	  <span style="color: #a52a2a;">|</span> k <span style="color: #a52a2a;">-&gt;</span> aux <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="color: #06c; font-weight: bold;">List</span></a><span style="color: #a52a2a;">.</span><span style="color: #060;">fold_left</span> f <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span> l<span style="color: #6c6;">&#41;</span> <span style="color: #6c6;">&#40;</span>k<span style="color: #a52a2a;">-</span><span style="color: #c6c;">1</span><span style="color: #6c6;">&#41;</span></pre></td></tr></table></div>

<p>List.fold_left est ce que l'on appelle un "pliage" (<em>fold</em> en Anglais). Pour vous familiariser avec ces derniers, une recherche sur "functional programming fold" devrait vous apporter le nécessaire <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). Il permet de parcourir la liste d'une certaine façon en appliquant une certaine fonction sur l'élément courant et le résultat de ce qui a été fait jusque là de la même façon, et ainsi de suite. </p>
<p>Enfin, définissons une fonction nth_cantor qui permet d'obtenir la liste des intervalles qui constituent la n-ème itéraction de la construction de l'Ensemble de Cantor.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code49'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23549"><td class="code" id="p235code49"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> nth_cantor <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">function</span>
  <span style="color: #a52a2a;">|</span> <span style="color: #c6c;">0</span> <span style="color: #a52a2a;">-&gt;</span> <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#40;</span><span style="color: #c6c;">0</span><span style="color: #a52a2a;">.</span>,<span style="color: #c6c;">1</span><span style="color: #a52a2a;">.</span><span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#93;</span>
  <span style="color: #a52a2a;">|</span> k <span style="color: #a52a2a;">-&gt;</span> map_n cantor_step <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#40;</span><span style="color: #c6c;">0</span><span style="color: #a52a2a;">.</span>,<span style="color: #c6c;">1</span><span style="color: #a52a2a;">.</span><span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#93;</span> k</pre></td></tr></table></div>

<p>On voit donc que l'on part de l'intervalle [0,1], et que l'on va répéter k fois l'itéraction. </p>
<p>Deux fonctions utilitaires, dont une qui utilise non pas le module List standard mais le module List de OCaml Batteries Included, pour la fonction print. (en fait, List.fold_left ci-dessus est également celui de OCaml Batteries Included, étant donné que le programme sera compilé avec OCaml Batteries Included).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code50'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23550"><td class="code" id="p235code50"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> couple_printer <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALoutput"><span style="color: #06c; font-weight: bold;">output</span></a> <span style="color: #6c6;">&#40;</span>a,b<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span> <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html"><span style="color: #06c; font-weight: bold;">Printf</span></a><span style="color: #a52a2a;">.</span><span style="color: #060;">printf</span> <span style="color: #3cb371;">&quot;(%f,%f)\n&quot;</span> a b
&nbsp;
<span style="color: #06c; font-weight: bold;">let</span> list_printer l <span style="color: #a52a2a;">=</span>  <span style="color: #5d478b; font-style: italic;">(* List.print couple_printer stdout l ;*)</span>  <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html"><span style="color: #06c; font-weight: bold;">Printf</span></a><span style="color: #a52a2a;">.</span><span style="color: #060;">printf</span> <span style="color: #3cb371;">&quot;\n%d intervals in list\n&quot;</span> <span style="color: #6c6;">&#40;</span><a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html"><span style="color: #06c; font-weight: bold;">List</span></a><span style="color: #a52a2a;">.</span><span style="color: #060;">length</span> l<span style="color: #6c6;">&#41;</span></pre></td></tr></table></div>

<p>La première permet d'afficher un couple de réels depuis ... un couple de réels.<br />
La seconde permet d'afficher une liste en précisant quelle fonction utiliser pour afficher chaque élément. Elle affiche ensuite la taille. Ici, le passage d'affichage des éléments est commenté (entre (* ... *)) car ayant testé mon code avec notamment 25 itérations, on se retrouve avec beaucoup trop de choses à afficher pour que ça soit supportable pour un être humain normal.</p>
<p>Enfin, le code qui est exécuté :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code51'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23551"><td class="code" id="p235code51"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> main <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span> 
  <span style="color: #06c; font-weight: bold;">try</span> 
    <span style="color: #06c; font-weight: bold;">let</span> n <span style="color: #a52a2a;">=</span> <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALint_of_string"><span style="color: #06c; font-weight: bold;">int_of_string</span></a> <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Sys.html"><span style="color: #06c; font-weight: bold;">Sys</span></a><span style="color: #a52a2a;">.</span><span style="color: #060;">argv</span><span style="color: #a52a2a;">.</span><span style="color: #6c6;">&#40;</span><span style="color: #c6c;">1</span><span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">in</span>
    <span style="color: #06c; font-weight: bold;">let</span> cn <span style="color: #a52a2a;">=</span> nth_cantor n <span style="color: #06c; font-weight: bold;">in</span>
      list_printer cn
  <span style="color: #06c; font-weight: bold;">with</span> _ <span style="color: #a52a2a;">-&gt;</span> <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALprint_endline"><span style="color: #06c; font-weight: bold;">print_endline</span></a> <span style="color: #3cb371;">&quot;Use : ./cantor n, where n is an integer&quot;</span> <span style="color: #a52a2a;">;</span> <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#VALexit"><span style="color: #06c; font-weight: bold;">exit</span></a> <span style="color: #c6c;">0</span>
&nbsp;
<span style="color: #06c; font-weight: bold;">let</span> _ <span style="color: #a52a2a;">=</span> main <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span></pre></td></tr></table></div>

<p>Pour  terminer, la compilation :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p235code52'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23552"><td class="code" id="p235code52"><pre class="shell" style="font-family:monospace;">$ ocamlfind batteries/ocamlopt -o cantor cantor.ml</pre></td></tr></table></div>

<p>(pas d'optimisation ici, si vous les voulez, rajouter -cc -O<em>n</em> après ocamlopt)</p>
<p>Et on exécute :</p>
<blockquote><p>$ time ./cantor 25<br />
33554432 intervals in list</p>
<p>real    0m25.553s<br />
user    0m23.481s<br />
sys     0m2.060s
</p></blockquote>
<p>En activant l'affichage des éléments, sur un petit nombre d'itérations :</p>
<blockquote><p>$ time ./cantor 4<br />
[(0.740741,0.753086)<br />
; (0.765432,0.777778)<br />
; (0.666667,0.679012)<br />
; (0.691358,0.703704)<br />
; (0.962963,0.975309)<br />
; (0.987654,1.000000)<br />
; (0.888889,0.901235)<br />
; (0.913580,0.925926)<br />
; (0.074074,0.086420)<br />
; (0.098765,0.111111)<br />
; (0.000000,0.012346)<br />
; (0.024691,0.037037)<br />
; (0.296296,0.308642)<br />
; (0.320988,0.333333)<br />
; (0.222222,0.234568)<br />
; (0.246914,0.259259)<br />
]<br />
16 intervals in list</p>
<p>real    0m0.013s<br />
user    0m0.000s<br />
sys     0m0.016s
</p></blockquote>
<p>Vous avez surement remarqué que cette méthode ne préserve pas l'ordre des intervalles... Ce n'a pas vraiment été mon soucis premier, et ce serait arrangé avec la méthode décrite ci-dessous.</p>
<p>Au passage, si j'utilisais des arbres binaires pour toutes les étapes intermédiaires et que je produisais une liste depuis cet arbre, je gagnerais pas mal en efficacité, disons que je vous le laisse à titre d'exercice <img src='http://www.coder-studio.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Enjoy !</p>
<p>PS : la capture d'écran ci-dessus provient d'un programme que j'avais réalisé il y a quelques mois et qui faisait une construction itérative représentée graphiquement, mais la méthode de génération était moins efficace, et j'ai la flemme de refaire la même chose maintenant...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/construction-de-lensemble-de-cantor-en-ocaml/feed/</wfw:commentRss>
		<slash:comments>1382</slash:comments>
		</item>
		<item>
		<title>OCaml Batteries Included : un effort pour fournir une bibliothèque standard digne de ce nom pour OCaml</title>
		<link>http://www.coder-studio.com/blog/ocaml-batteries-included-un-effort-pour-fournir-une-bibliotheque-standard-digne-de-ce-nom-pour-ocaml/</link>
		<comments>http://www.coder-studio.com/blog/ocaml-batteries-included-un-effort-pour-fournir-une-bibliotheque-standard-digne-de-ce-nom-pour-ocaml/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 20:36:57 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
				<category><![CDATA[Langages fonctionnels]]></category>
		<category><![CDATA[batteries]]></category>
		<category><![CDATA[fonctionnel]]></category>
		<category><![CDATA[included]]></category>
		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://www.coder-studio.com/blog/?p=193</guid>
		<description><![CDATA[Bonsoir, Peut-être avez-vous déjà entendu parler de ce projet ... OCaml Batteries Included. Ce projet couvre pour le moment un certain nombre de domaines. Il fournit une certaine quantité de structures de données, de fonctions pour la programmation concurrente, etc. Qui plus est, il inclut des extensions de syntaxes qui pourront s'avérer très utile, ainsi [...]]]></description>
			<content:encoded><![CDATA[<p>Bonsoir,</p>
<p>Peut-être avez-vous déjà entendu parler de ce projet ... <a href="http://batteries.forge.ocamlcore.org/">OCaml Batteries Included</a>.</p>
<p>Ce projet couvre pour le moment un certain nombre de domaines. Il fournit une certaine quantité de structures de données, de fonctions pour la programmation concurrente, etc. Qui plus est, il inclut des extensions de syntaxes qui pourront s'avérer très utile, ainsi que de nouveaux opérateurs pour rendre le code OCaml plus lisible et concis, ce qui finalement fait gagner en lisibilité (notamment pour l'enchainement de fonctions, comme lorsque l'on appelle une série de fonctions opérant sur une chaîne de caractères, en passant le résultat d'une fonction à la suivante, et ainsi de suite). Je ne vais pas lister les bibliothèques, ce serait trop long.</p>
<p>OCaml Batteries Included est sortie en version Bêta 1 il y a quelques jours. Qui plus est, l'équipe OCaml-Debian-Maintainers a mis à disposition un paquet ocaml-batteries-included qui est dans le dépôt testing officiel, n'hésitez pas !</p>
<p>Pour finir, quelques liens :<br />
<a href="http://batteries.forge.ocamlcore.org/">Site officiel</a><br />
<a href="http://batteries.forge.ocamlcore.org/doc.preview:batteries-beta1/html/api/index.html">Documentation de l'API</a><br />
<a href="http://batteries.forge.ocamlcore.org/doc.preview:batteries-alpha3/html/index.html">Documentation de la plateforme</a><br />
<a href="http://dutherenverseauborddelatable.wordpress.com/2009/04/06/ocaml-batteries-included-beta-1/">Billet de blog sur la publication de la Beta 1</a></p>
<p>Enjoy !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coder-studio.com/blog/ocaml-batteries-included-un-effort-pour-fournir-une-bibliotheque-standard-digne-de-ce-nom-pour-ocaml/feed/</wfw:commentRss>
		<slash:comments>2221</slash:comments>
		</item>
	</channel>
</rss>

