Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does weird notation after type class declaration mean [duplicate]

In ghci :i Functor gives me:

class Functor (f :: * -> *) where
  fmap :: (a -> b) -> f a -> f b
  ...

What does (f :: * -> *) mean? It looks as if f needs to be a function, but that doesn't make sense.

like image 697
hgiesel Avatar asked Jul 28 '26 07:07

hgiesel


1 Answers

The asterisk * is the Haskell symbol for kinds, the "types of types".

Prelude> :k Int
Int :: *
Prelude> :k Maybe
Maybe :: * -> *
Prelude> :k []
[] :: * -> *
Prelude> :k Maybe Int
Maybe Int :: *

The Functor class is defined for type constructors of kind * -> *, which take one type and return a type.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!