Closed lp74 closed 5 years ago
Yes! Why would it flatten it :sweat_smile: ? of
is use to put a value in context of a given Functor. If you want to put a Functor inside a Functor, that's totally fine.
of :: Functor f => a -> f a
Remember that in a Hindley-Milner type signature, lowercase letters are variables that can represent any type (modulo the constraints we put upfront). Same letters corresponds to same types. So, if you give of
a list of [a]
, you end up with:
of :: Functor f => [a] -> f [a]
Now, we can also specialize the Functor because, we know it's a list, and our specialized signature become:
of :: [a] -> [[a]]
So, no problem :)
Thank you for the explanation
The List.of method doesn't flatten arrays. Passing [a] as arguments, it wraps the array as [[a]].
Is there a reason?