Recently in haskell Category

Happy Pi Day!

| | Comments (0) | TrackBacks (0)

For those who put the month before the day (why?), today is 3/14: Pi day.

So happy Pi day! Have some pi:

let p d = take d(fix(\i y h->let(z,x)=fix(\f xs->case xs of{((n,d,c):y)->let{(z,k)=f
y;(q,r)=(c*10+k)`divMod`d}in((n,d,r):z,n*q);_->([],0)})y in case x of{9->i z(h++[9])
10->i z(map(\x->(x+1)`mod`10)h++[0]);_->h++i z[x]})((1,10,2):[(i,2*i+1,2)
|i<-[1..(10*d)`div`3]])[])in p 100

Feel free to change the "100" at the end to however much precision you need.

The BBC reports that a rebuilt Colossus is cracking codes again at Bletchley Park.

COLOSSUS was the world's first programmable electronic computer, so this is considered something of an achievement. However, COLOSSUS was really only built to do one job.

Read on for details.

Correct by construction

| | Comments (0) | TrackBacks (0)

While I'm on the topic of axioms and laws...

Suppose you're defining an interesting new abstraction. How can you tell what is a good set of laws to define, and what's redundant?

My opinion (which is worth exactly what you paid for it) is that good laws provide a clear way to implement a the abstraction that is correct by construction. You can easily see this by constructing one.

More ramblings follow.

Laws on the cheap

| | Comments (0) | TrackBacks (0)

While we're on the topic, here's something that's been bugging me for a few years now.

There are three monad laws in Haskell, and they make a lot of sense, especially when you write them in do-notation form. They're very-well motivated, and they're clean.

Arrows are a very pretty generalisation of "notions of computation" (you can think of them as extending monads to not-just-straight-line computation). However, some of the laws that they obey are much more poorly motivated. I figured that this was because they were based on Freyd categories, which are abstract things which obey silly, technical laws.

I'm happy to report that I was wrong. We hereby motivate some of the arrow laws.

Free as in theorems

| | Comments (0) | TrackBacks (0)

The programming language Haskell (under reasonable conditions) has this cool property, known as parametricity. Intuitively, it means that all functions of a certain type share certain properties.

After Phil Wadler, we refer to any such property as a "free theorem". In the ramblings that follow, I muse on exactly what they mean.

About this Archive

This page is a archive of recent entries in the haskell category.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.1