Effective Haskell: Chapter 6 - HKT and Polymorphism

In toCsv (ePub p 157, dropLeadingComma will leave a leading space. In the case statement, the first case is ‘,’:s’ → s’ and it should be ‘,’:’ ‘:s’ → s’

Also p 157. “Notice in the type signatures for the fold functions that we have a type class constraint on t, but in our type signature we’re applying the type a to t. That’s because t is a higher kinded type variable …” This is a bit terse (after reading it over a few times, I realized that this is really mind-blowing :slight_smile: ). I wonder if there could be some additional discussion relating the applying types (e.g., applying types to Either) to higher kinded variables.

1 Like

The “Deriving Nullable” portion of the exercises could be expanded a bit. I’m not sure what is meant by being asked to “create derived instance of Nullable for optional types, while allowing you to easily select which distance you would like to use.”

1 Like

I think the code on page 235 of the most recent PDF

module InferredTypeDemo where

convertViaInt :: forall {a} b. (Integral a, Num b) => a -> b
convertViaInt input = fromIntegral $ fromIntegral @_ @Int input

will not parse correctly (in particular, the use of brackets) on ghci < 9. Might be good to add a note to that effect.

Also, on page 238, we have

First, since we didn’t define Monoid or Int ourselves, we can use a newtype wrapper to avoid creating an orphan instance. We also have the problem of there being two perfectly good potential instances that we’re interested in. We can solve that by creating two typeclasses, one for each instance we’re interested in:

newtype Product = …
newtype Sum = …

But it looks like we’re defining two types, and not two typeclasses.