
Den tors 12 juli 2018 13:15Francesco Ariis
Hello Patrik,
On Thu, Jul 12, 2018 at 12:05:52PM +0200, mrx wrote:
Why is the type class called `Read`? What am I missing above?
we can say any instance of `Read` has to implement
read :: Read a => String -> a -- the actual instance implements a different function, -- but that's not relevant for our example
So, a typeclass (Read, capital `r`) gives us a function (`read`, lower-case `r`). The function goes from `String` (and no other things) to our implemented type.
That makes sense to me based on the type, sure. So read is some form of casting then? Does this answers your question? Maybe, but I still don't see what I'd use it for. Is it used to for example read the contents of a file whose file name is provided as that string? // Patrik