Diff: 79539df30 | faq | css

Merge branch 'master' of bitcheese.net:/var/gits/bwiki

Merged: 3ecd39c784becf314abf1b5c59cf64bdbf0c1c78 f0dc2221bccafc408858023da1cb656006dea6cb

File created: haskell-sucks [Diff]

-- /dev/null++ b/haskell-sucks
@@ -1 +1,57 @@
h1. Where Haskell Sucks

h2. Records

Records' syntax sucks ass. Let's look at this code example:

bc. data VisualType = VisualType {
visualId :: Word32,
visualClass :: VisualClass,
bitsPerRgbValue :: Word8,
colormapEntries :: Word16,
redMask :: Word32,
greenMask :: Word32,
blueMask :: Word32
}

Here we:

# Pollute function namespace with names of every record field
# Have to go through quite some hoops to change record's value

Changing value of a field:

bc. vtype {redMask = 666}

It's not a function. It's pure syntax shit. Cons are:

You can't curry this. To change field of every enrty in list, you'll have to make lambdas:

bc. map (\vt -> vt {redMask = 666}) vtypes

To prevent namespace pollution, you can stick every data structure in module of its own and disambiguate like this:

bc. VisualType.redMask vt

But that still sucks.

Possible solution of this would be adding something like C data structures, so you can do

bc. vt ->redMask

Where "->redMask" is a postfix function, and it can be curried, passed aroud, or whetever. for changin fields, something like in ruby can be used:

bc. vt ->redMask= 666

Where "->redMask=" is another postfix operator.

h2. base library sucks

Haskell has brilliant thing: infinite integral types.

Let us use them for indexes? Well, we can: there are genericLength and friends. If you use !! (:: [a] -> Int -> a) though, which is simplier, you are fucked if you suddenly need larger indexes. Indexes are barely a problem though.

Let us use Infinity like any other number? No. We can only get it, and NaN, as results of arithmetic operations, and check for them. Moreover, division by zero raises an error.

Other brilliand thing in Haskell: Maybe. But standard library seems to avoid it whenever necessary. Pass shit to *read*, *!!*, *tail*, *init*, etc. and get an error.

By Alexander Markov on Wed Jan 27 15:14:06 +0000 2010