Given the following code (copied from the attoparsec library) what does the inline pragma do? I suppose it makes sense for only fmapR to be inlined, but not the other fmaps which are defined in other Functor instances.
instance Functor (IResult t) where
fmap = fmapR
{-# INLINE fmap #-}
The inline pragma will copy the contents of the function (in this case
fmapR) to the location where it is called, if the compiler can prove that the functor being used isIResult.The function cannot be inlined in the following case, because the definition of
fmapis not known:Here, however, it is known, because a certain functor is being used, and the function can be inlined: