I'm Having problems understanding functors, specifically what a concrete type is in LYAH. I believe this is because I don't understand what []
really is.
fmap :: (a -> b) -> f a -> f b
- Is
[]
, a type-constructor? Or, is it a value constructor? - What does it mean to have the type of:
[] :: [a]
? - Is it like
Maybe
type-constructor, orJust
value constructor?- If it is like
Just
then how comeJust
has a signature likeJust :: a -> Maybe a
rather thanJust :: Maybe a
, in other words why isn't[]
typed[] :: a -> [a]
- If it is like
- LYAH says this as it applies to functors: Notice how we didn't write instance Functor [a] where, because from fmap :: (a -> b) -> f a -> f b, we see that the f has to be a type constructor that takes one type. [a] is already a concrete type (of a list with any type inside it), while
[]
is a type constructor that takes one type and can produce types such as [Int], [String] or even [[String]]. I'm confused though the type of[]
implies it is like a literal for[a]
what is LYAH trying to get at?