
On Mon, Mar 23, 2015, at 03:55 AM, Henk-Jan van Tuyl wrote:
On Sun, 22 Mar 2015 14:16:14 +0100, Ramakrishnan Muthukrishnan
wrote: Hello Haskellers:
A few weeks ago, there was this thing called "Go challenge" and a problem was posted¹ on decoding a binary format and printing out the drum sequences in the input binary file.
I made a Haskell solution and would love to get some code reviews.
in line put _ = do BinaryPut.putWord8 0 -- we don't care about writing the 'do' is not necessary, as there is only one action; you could also write: put _ = undefined -- we don't care about writing or: put _ = error "put is not implemented"
The line (intercalate "\n" $ map show tracks') can be simplified to (unlines $ map show tracks')
The line putStrLn (show (runGet get bs :: Splice)) can be simplified to print (runGet get bs :: Splice) as print is the same as putStrLn . show
Instead of: else do track <- getTrack tracks' <- getTracks return (track:tracks') you could write: else liftM2 (:) getTrack getTracks or: else getTrack ^:^ getTracks where (^:^) = liftM2 (:) (import Control.Monad first)
Hello Henk-Jan, Thanks a lot for all the suggestions.
You can use hlint (from Hackage) to get some hints for possible improvements of the code.
Thanks. I ran HLint and it gave some more suggestions. Incorporated all the suggestions, thanks a lot. Ramakrishnan