One way to do this is by taking note of how EndPackage works -- by adding \$Context to \$ContextPath:
ChurchNumerals`Private`prevContext = Context[];BeginPackage["ChurchNumerals`"]; ZERO::usage = "ZERO is the Church numeral encoding of zero"; ONE::usage = "ONE is the Church numeral encoding of the integer 1"; TWO::usage = "TWO is the Church numeral encoding of the integer 2"; Begin["`Private`"]; ZERO = Function[f, Function[n, n]]; ONE = Function[f, Function[n, f[n]]]; TWO = Function[f, Function[n, f[f[n]]]]; End[]; $Context = ChurchNumerals`Private`prevContext;EndPackage[];
Now the package is on $Packages
but not $ContextPath
, and is used qualified with the package name:
Map[#[Function[n, n + 1]][0] &, {ChurchNumerals`ZERO, ChurchNumerals`ONE, ChurchNumerals`TWO}]