I tried to convert Haskell code that calculates the Adler-32 hash of 'a' into Frege but got 6422626 instead of 300286872
Excerpt from the Haskell code at http://book.realworldhaskell.org/read/functional-programming.html
adler32_try2 xs = helper (1,0) xs
where helper (a,b) (x:xs) =
let a' = (a + (ord x .&. 0xff)) `mod` base
b' = (a' + b) `mod` base
in helper (a',b') xs
helper (a,b) _ = (b `shiftL` 16) .|. a
Excerpt from the Frege code at https://github.com/Dierk/Real_World_Frege/blob/master/realworld/chapter4/G_Reducing.fr
adler32 xs = accuAdler (1,0) xs where
accuAdler (a,b) (y:ys) =
let newA = (a + (ord y `band` 0xff)) `mod` base
newB = (newA + b) `mod` base
in accuAdler (newA, newB) ys
accuAdler (a,b) _ = (b `bshl` 16) `bor` a
Is the choice of operators wrong or the signed/unsigned 32/64 integer properties?