Greek VAT validator in Haskell

I’ve recently started trying to learn Haskell, just for the fun of it and i thought i’d try solving a couple of small real-world problems to get my feet wet.

So here is a Greek VAT validator in Haskell:

afmValidate :: String -> Bool
afmValidate x
    | length x /= 9 = False
    | checkDigit == (last n) = True
    | otherwise = False
    where n = List.map (\z -> read [ z ] :: Integer) x
          checkDigit = (sum (zipWith (\x y-> x * (2^y) ) (reverse $ init n) [1..8]) ) `mod` 11 `mod` 10

Supposedly people use single letter variable names in Haskell routinely. I’m guessing because most functions are very very small and simple and look like mathematics more than code. I feel like a filthy whore for doing that and i’m not sure where to strike a balance between single letter variables and long-descriptive variables.

Comments !

blogroll

social