Posts filed under “Uncategorized”

Perl6 ternaries and Haskell Maybe

Just a quick post as I've not had a lot of time to play with Haskell just recently. This morning I noticed Jonathan Lang's post to perl6-language asking if the ternary operator ?? !! could be turned into two binary operators. I thought this had been discussed some time back, but apparently not. Audrey commented […]

Chapter 7: Trees

I start off confidently, typing in the first example into my scratch file: > data Tree = Leaf a | Branch (Tree a) (Tree a) Of course, ghci complains bitterly, and strangely Prelude> :l 7.hs [1 of 1] Compiling Tree ( 7.hs, interpreted ) 7.hs:5:19: Not in scope: type variable `a' 7.hs:5:36: Not in scope: […]

Chapter 6: Shapes III: Perimeters

(Haven't really had much time for Haskell this week – I had set myself the task of comparing some versions of SOE exercises, but will get back to that as soon as I can.  In the mean time, another (shortish) post in the regular series…) The first part is straight forward enough. We create a […]

Chapter 5: Polymorphic and Higher-Order functions

This is an interesting chapter, working on the higher order functions rather than actually drawing shapes. It covers: Polymorphic types Principal type – this is an interesting idea, the type inferencer can determine that something works on an Int, say, or “Number stuff”, or “just any stuff”, or “a list of stuff”. Too general and […]

Chapter 4: Shapes II, drawing Shapes (short)

We are presented with some coercion functions and asked Ex 4.1: Why is inchToPixel x not defined as 100 * round x ? It is instead defined as round(100 * x). This is because if rounding was done on the input parameter, then whether it was, say, 1.01 or 1.99, the answer would be the […]

Meta: Shaving the Haskell blog yak

HTML is all very well and good, but frankly, I'm too lazy to mark up my&,<,> characters all the time by hand, at least withincode.  I used the POD formatter pod2html for a couple of earlyposts.  It's OK, it basically has a concept of "This is a normal textparagraph, and this is a code paragraph" […]