<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Random Hacks: 8 ways to report errors in Haskell</title>
    <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Technology and Other Fun Stuff</description>
    <item>
      <title>"8 ways to report errors in Haskell" by tphyahoo</title>
      <description>&lt;p&gt;right, uh, with whitespace :)&lt;/p&gt;


	&lt;p&gt;example4a x y = maybe ( putStrLn &amp;#8220;Division by zero&amp;#8221; ) ( putStrLn . show ) ( myDiv4 x y)&lt;/p&gt;


	&lt;p&gt;example4b x y = either putStrLn ( putStrLn . show ) ( myDiv4 x y )&lt;/p&gt;</description>
      <pubDate>Wed, 09 Jan 2008 10:46:48 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:40a56fb7-62d3-443b-9a1d-89ab2101380f</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-548</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by tphyahoo</title>
      <description>&lt;p&gt;uh, sorry, what I meant was&lt;/p&gt;


	&lt;p&gt;example4a x y = maybe ( putStrLn &amp;#8220;Division by zero&amp;#8221; ) ( putStrLn . show ) ( myDiv4 x y)
example4b x y = either putStrLn ( putStrLn . show ) ( myDiv4 x y )&lt;/p&gt;</description>
      <pubDate>Wed, 09 Jan 2008 10:46:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f6f166d8-06ed-4c2f-9c19-3fa93f0e7c48</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-547</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by tphyahoo</title>
      <description>&lt;p&gt;Or (wrt what I just said) you could do what Luis Cabellos suggested above.&lt;/p&gt;


	&lt;p&gt;Also, examples 4b and 4c could be rewritten without the case statements by using the maybe/either functions.&lt;/p&gt;


	&lt;p&gt;example4a x y = maybe
    ( putStrLn &amp;#8220;Division by zero&amp;#8221; )
    ( putStrLn . show )&lt;/p&gt;


	&lt;p&gt;example4b x y = either
    putStrLn
    ( putStrLn . show )&lt;/p&gt;


	&lt;p&gt;I suspect there&amp;#8217;s an idiom for doing this with IO as well but I don&amp;#8217;t know it.&lt;/p&gt;</description>
      <pubDate>Wed, 09 Jan 2008 10:43:30 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b91dba8e-3746-41fe-b5d3-5f2595967d52</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-546</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by tphyahoo</title>
      <description>&lt;p&gt;You need to import Control.Monad.Error for the Either stuff to work in example 4b or you get &amp;#8220;No instance for (Monad (Either String))&amp;#8221;&lt;/p&gt;


	&lt;p&gt;I think possibly this used to work, but stopped working at some point due to a reorganization of the haskell standard libs.&lt;/p&gt;


	&lt;p&gt;Thanks for putting this great post together.&lt;/p&gt;</description>
      <pubDate>Wed, 09 Jan 2008 10:35:16 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:82f9dedb-17a7-40d5-9aa0-ad9e41e0cd7b</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-545</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by Luis Cabellos</title>
      <description>&lt;p&gt;Great Post!&lt;/p&gt;


	&lt;p&gt;I found one code error. To test #3 way we need to add this:&lt;/p&gt;


&lt;pre&gt;instance Monad (Either a) where
  (Right x) &amp;gt;&amp;gt;= k = k x
  (Left err) &amp;gt;&amp;gt;= k = Left err
  return = Right
&lt;/pre&gt;</description>
      <pubDate>Tue, 23 Oct 2007 06:27:03 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:cdaebc43-552a-42f2-a762-63524f93ed3d</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-523</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by xml security geek</title>
      <description>&lt;p&gt;Yea, Haskell is nice to play with, but such inconsistencies still make it less appealing for serious development(((&lt;/p&gt;</description>
      <pubDate>Sat, 31 Mar 2007 23:03:46 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:98f8739f-dae2-4afa-91c0-3b8e60bd4e04</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-384</link>
    </item>
    <item>
      <title>"8 ways to report errors in Haskell" by David Waern</title>
      <description>&lt;p&gt;Hi,&lt;/p&gt;


	&lt;p&gt;Nice post! I&amp;#8217;ve been bugged by these issues myself. It would be nice to have standards/conventions for this.&lt;/p&gt;</description>
      <pubDate>Sun, 11 Mar 2007 13:06:42 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:f38589eb-2fc6-4193-afb5-4cdd7616dc29</guid>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors#comment-348</link>
    </item>
    <item>
      <title>8 ways to report errors in Haskell</title>
      <description>&lt;p&gt;Haskell is a marvellous language, but there are some things I don&amp;#8217;t like about it.  My least favorite: Haskell has no fewer than 8
different APIs for reporting errors.&lt;/p&gt;

&lt;p&gt;To make a bad situation worse, the choice of API varies between 
popular libraries. To give a particularly unfortunate example,
&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/network/Network-URI.html"&gt;Network.URI.parseURI&lt;/a&gt; and &lt;a href="http://www.haskell.org/http/api/Network-HTTP.html"&gt;Network.HTTP.simpleHTTP&lt;/a&gt; report
errors in entirely different ways, turning a &amp;#8220;download this URL&amp;#8221; program into a &lt;a href="http://darcs.haskell.org/http/test/get.hs"&gt;page of code&lt;/a&gt;,
nearly half of which is devoted to dealing with various kinds of errors. (The rest is boilerplate that could be refactored into a nice wrapper.)&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s begin with a toy function, the simplest possible program that could
actually fail:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_haskell "&gt;&lt;span class='varid'&gt;myDiv&lt;/span&gt; &lt;span class='varid'&gt;x&lt;/span&gt; &lt;span class='varid'&gt;y&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='varid'&gt;x&lt;/span&gt; &lt;span class='varop'&gt;/&lt;/span&gt; &lt;span class='varid'&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As every algebra student knows, we can&amp;#8217;t divide by zero.  Using this
function as our example, let&amp;#8217;s take a look at all the different ways we
can implement error-reporting in Haskell.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors"&gt;Read More&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 10 Mar 2007 19:05:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:226356a7-21bf-493b-aa23-59dccc766054</guid>
      <author>Eric Kidd</author>
      <link>http://www.randomhacks.net/articles/2007/03/10/haskell-8-ways-to-report-errors</link>
      <category>Haskell</category>
      <trackback:ping>http://www.randomhacks.net/articles/trackback/347</trackback:ping>
    </item>
  </channel>
</rss>
