haskell - What does the 'f' represent in the fmap function of a functor? -


i'm looking @ following function:

fmap :: (a -> b) -> f -> f b 

and want understand 'f' is, in (f a or f b). article reading describes 'box' what's actual correct name it? type variable? think i'm confusing , thinking it's function application - correct?

your intuition kind of function application correct, not regular functions. instead, application of type constructors on type level.

specifically, functors must have kind (type-of-type) * -> * means take 1 type argument , produce concrete type * such as, example, [int].

examples of such type constructors include io, maybe, [], either e , many others, , these specific examples have valid functor instances.

fmap (+1) [1,2,3]    :: [] int -- known [int]   = [2,3,4] fmap (+1) (just 1)   :: maybe int   = 2 fmap (+1) (right 1)  :: either e int   = right 2 fmap (+1) (return 1) :: io int -- uses monad io instance   "=" 2 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -