Diff: [root] @ 79539df3075 | faq | css

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

Merged: <a href="/diff/3ecd39c784becf314abf1b5c59cf64bdbf0c1c78">3ecd39c784becf314abf1b5c59cf64bdbf0c1c78</a> <a href="/diff/f0dc2221bccafc408858023da1cb656006dea6cb">f0dc2221bccafc408858023da1cb656006dea6cb</a>

File created: 33188 haskell-sucks [Diff]

diff --git a/haskell-sucks b/haskell-sucks
new file mode 100644
index 0000000..af70d36
-- /dev/null
++ b/haskell-sucks
@@ -0,0 +1,56 @@
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.
\ No newline at end of file

By Alexander Markov on 2010-01-27 18:14:06 +0300 Powered by bitcheese wiki engine