Hacker News new | ask | show | jobs
by kazagistar 3993 days ago
It is a lot less of a problem then you make out: most of the time, the single letter naming conventions are actually very useful. Its not like all the haskellers just forgot the usefulness of names from the other languages they frequently use; it is an educated and measured choice.

That said, it certainly can be taken too far and turn into a clusterfuck.

    permutations            :: [a] -> [[a]]
    permutations xs0        =  xs0 : perms xs0 []
      where
        perms []     _  = []
        perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)
          where interleave    xs     r = let (_,zs) = interleave' id xs r in zs
                interleave' _ []     r = (ts, r)
                interleave' f (y:ys) r = let (us,zs) = interleave' (f . (y:)) ys r
                                         in  (y:us, f (t:y:us) : zs)
1 comments

    addart a = array ((-1,0),(n,m+n)) $ z ++ xsi ++ b ++ art ++ x
      where z = ((-1,0), a!(0,0)) : [ ((-1,j),0) | j <- [1..n] ] ++ [ ((-1,j+n),a!(0,j)) | j <- [1..m] ]
            xsi = ((0,0), -colsum a 0) : [ ((0,j),0) | j <- [1..n] ] ++ [ ((0,j+n), -colsum a j) | j <- [1..m] ]
            b = [ ((i,0), a!(i,0)) | i <- [1..n] ]
            art = [ ((i,j), if i == j then 1 else 0) | i <- [1..n], j <- [1..n] ]
            x = [ ((i,j+n), a!(i,j)) | i <- [1..n], j <- [1..m] ]
            ((_,_),(n,m)) = bounds a

From Matrix.Simplex https://hackage.haskell.org/package/dsp-0.2.1/docs/src/Matri...
https://hackage.haskell.org/package/dsp-0.2.1/docs/src/Matri... link to the function itself

Never really seen something like this before, really hope someone will clean it up

To be fair it looks to be a relatively complex operation. Do you know how any other languages implement this?
This is not about the complexity of the code, but about variables with or without meaningful names.
I feel like xsi and art mean something domain specific that might be obvious to a domain expert.