I have been ill the last few days, so have not written any posts but I did watch a few YouTube videos around on Haskell and JavaScript.
Kata
Haskell Kata
One particular video made me realise that I have not been using the Haskell type signatures to help in describing the functions well enough, and the video makes a good case stating that type signature declarations aid in code documentation, however I have tended to be lazy and not use type aliases.
So I set out to Kata this morning to practice using them by adding the conversion from generic concrete types to type aliases as a refactoring step in the TDD process. As the video rightly pointed out that this makes the code a lot more readable. The code that was shown in the video was very human readable, even to those that may not know Haskell (a criticism of Haskell is often its shorthand notation, which makes it not human readable), but the video proved otherwise.
The video can be viewed here: Communicating in Types
A snippet from my kata can be seen below. Beforehand I would leave the type signature as isCountTooMany :: [(Int, Int)] -> Int -> Bool
.
type CountLimit = Int
type NumberAndCount = (Int, Int) -- key value pairs for Number and Count
isCountTooMany :: [NumberAndCount] -> CountLimit -> Bool
isCountTooMany numAndCount n = foldr isCountEqualN False numAndCount
where isCountEqualN = \a b -> ((snd a) > n ) || b
^^^Terrible syntax highlighting in this version of markdown :(
Non-kata Kata
This morning, one of the the Software Crafters involved in the scheme, showed us how to tackle a task; be it for a product team or personal things (e.g. blogging). And it was to basically break down the task into sub-dependencies, list and sub list things until you have a clear plan of what needs to be done. By sub-listing you can see what is required before the parent task can be started. I guess this is something that I kinda of do in my day-to-day but not as methodical, but shall try to be so in the future.
Functors Pending
I was going to include a post about functors and did write half of it, but I still haven’t finished that chapter in the book so I am going to save it for my next post, and may even do a presentation on it next week.