Usually, when you're wondering about a library function, you should use CPP.
{-# language CPP #-}
#if !MIN_VERSION_base (4,10,0)
fromRight :: ...
#endif
The MIN_VERSION_...
macros used to be provided by Cabal; now they're provided by GHC. If you want to use them with sufficiently old versions of GHC, you'll need to use Cabal (using either cabal-install
or stack
).
Before you go to the trouble of doing this, note that there are several packages with names ending in -compat
that do all the work for you. In this case, you can use the fromRight
from Data.Either.Compat
in the base-compat
package. Then you don't have to care whether you're using a new enough base
library.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…