Hacker News new | ask | show | jobs
by cousin_it 2389 days ago
> we can think of a monad as a datatype with

Aaaaaaa

Be more precise about instance relations! They are the first source of confusion!

- String is a type. The value "abcde" is an instance of that type.

- Num is a typeclass. The type Int is an instance of that typeclass. The value 12345 is an instance of that type.

- Monad is a typeclass whose instances are generic types. The generic type List is an instance of that typeclass. The type List Int is an instance of that generic type. The value [1,2,3] is an instance of that type.

Explaining the operations of Monad is only useful when you're comfortable with "value belongs to type which belongs to generic type which belongs to typeclass".

2 comments

And if you think about it, you're just asking the author to be clear about the types of the things they are talking about.
Is there really a need to distinguish between types and typeclasses though?

You can have a notion of type and inheritance where Monad is a type, and Lists, Promises, Option, etc. are subtypes of Monad.