From my experience, such small functions will be inlined automatically and across module borders, if it makes sense.
You can check whether GHC decided to make that possible, by running ghc --show-iface
on the resulting .hi
-File. If it says something about an Unfolding
as in the follwing example, when using this module the function will likely be inlined:
$ ghc --show-iface /usr/lib/ghc/base-4.6.0.1/Data/Either.hi
Magic: Wanted 33214052,
got 33214052
...
38da29044ff77a85b08cebca1fed11ad
either :: forall a c b.
(a -> c) -> (b -> c) -> Data.Either.Either a b -> c
{- Arity: 3, HasNoCafRefs, Strictness: LLS,
Unfolding: (\ @ a
@ c
@ b
f :: a -> c
ds :: b -> c
ds1 :: Data.Either.Either a b ->
case ds1 of wild {
Data.Either.Left x -> f x Data.Either.Right y -> ds y }) -}