
Hi to everyone, I'm learning Haskell going through Thompson's craft of functional programming (3rd ed). As of now I've reached Chapter 13 where classes definition and instances are discussed. At some point the "Info a" class is introduced which has the following interface: class Info a where examples :: [a] size :: a -> Int then it goes on explaining that every instance of that class must comply to the interface shown. So far so good. My perplexities start when actual instances are implemented. Take, for example the following one: instance Info Int where examples = [-100..100] size _ = 1 I promptly tried to fiddle with this via ghci and while I was able to access the "size" function of the interface I have no clue about how to reach the "examples" part and that prevents me from understanding the next step when an instance of "Info [a]" is discussed. About that I don't quite get the definition of its "examples", and the reasons it is defined taking into accounts "all the one and two element lists that can be built up from exmaples of type a" (cit.) Can anyone shed some light about this, please? Thanks in advance for your help. Best regards, Carmine