Data.Foldable shows the following algebraic data type:
data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
Its kind
is * -> *
. It requires an a
type.
Prelude> :k Tree
Tree :: * -> *
Let's look now at trait Foldable[_]
, a "higher-kinded type" from Scala from Functional Programming in Scala:
trait Foldable[F[_]] {
def foldRight[A,B](as: F[A])(z: B)(f: (A,B) => B): B
...
}
The excellent book says:
Just like values and functions have types, types and type constructors have kinds. Scala uses kinds to track how many type arguments a type constructor takes, ...
EDIT
When specifying trait Foldable[F[_]]
, does the F[_]
always indicate a higher-kinded type? Is it possible for F[_]
to be anything else? Could it be a type - F[A]
?