In my quest to re-learn Haskell I eventually thought: “OK, let’s see how an exception looks like”. Starting my favorite interactive Haskell implementation:

   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.4.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base-1.0 ... linking ... done.
Prelude>

OK. Let’s generate an exception now, a division by zero for example (something basic):

Prelude> 1 / 0
Infinity

Woa! Infinity ? Programming languages were not supposed to know about such things. Is it a real concept of Infinity or just a little label:

Prelude> (1 / 0) * 5
Infinity

OK, so far, it behaves good. Diving infinity by infinity is even more invalid that dividing one by zero, that surely has to raise an exception:

Prelude> (1 / 0) / (1 / 0)
NaN

Not A Number ? mmmhhh… My quest for an exception failed, back to the gentle guide (and thinking how GUIs and statistics programs would output the correct ‘values’ Inifinity and NaN to the user without a long sets of ifs)


2 responses to “Trying to find exceptions in Haskell”

  1. […] Division by zero! I can't divide by zero (I'm not Haskell) bloh:234: bluh(…) blih:452: bloh(…) bleh:34: blih(…) blah:94: bleh(…) blah_test:754: […]

  2. […] Division by zero! I can't divide by zero (I'm not Haskell) bloh:234: bluh(…) blih:452: bloh(…) bleh:34: blih(…) blah:94: bleh(…) blah_test:754: […]

Leave a Reply

Hi, I'm Pablo, this is my web site. You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 4,048 other subscribers

I'm writing a book

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I've been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git ham radio history idea Java Keep on Posting Kubuntu Lisp Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek startups technology Ubuntu web WordPress

I've been writing for a while:

%d bloggers like this: