let's allow programmer to create new types with type constructors. a type constructor can take some existing type. this seems like a powerful and useful idea! (it really is)
aha, we got more complex types! let us think of a presentation for the types. the simple types will be marked *. The type that takes in another type will be * -> *.
god, looks like they are gonna use Either - it has signature * -> * -> *
let's provide a command :kind to help decide on how complex are the types
for certian types, we want to require a set of methods, that will work just for them. that's a reasonable idea!
a group of types will be called type class. when specifing a type class we will list the required methods (functions) that should work on each type in this group
how do we know a specific type is within a type group (class) - it will be declared with an instance
what if the methods need to work slighty diffrently with each type - when defining an instance - make it happen
can a type be a part of different type classes? absolutely!
can type classes be embedded inside one another? sure, that will allow a useful system of types and their classes
typeclass is a constraint on types! see kind of any typeclass, it is written there
so, still wtf is Monad? it is a group of types with signature * -> * (complex types) with a requirement to have some functions that work with a specific type. there are many types * -> * that are memebers of this group of types, or instances of the typeclass.
Int
,Char
, ...*
. The type that takes in another type will be* -> *
.* -> * -> *
:kind
to help decide on how complex are the typesinstance
* -> *
(complex types) with a requirement to have some functions that work with a specific type. there are many types* -> *
that are memebers of this group of types, or instances of the typeclass.