nixpkgs/pkgs/top-level
Russell O'Connor d4bd4650d6 Rework the knot-tying code for defining Haskell packages.
The existing knot-tying code I felt was a bit incoherent with result, finalReturn, self, refering to different various forms of the "haskellPackages" value and often
different forms in the same place.

This commit instills some object-oriented discipline to the construction of hasekllPackages using a small number of fundamental OO concepts:

* An class is a open recursive function of the form (self : fooBody) where fooBody is a set.
* An instance of a class is the fixed point of the class.
  This value is sometimes refered to as an object and the values in the resulting set are sometimes refered to as methods.
* A class, foo = self : fooBody, can be extended by an extension which is a function bar = (self : super : barBody) where barBody a set of overrides for fooBody.
  The result of a class extension is a new class whose value is self : foo self // bar self (foo self).
  The super parameter gives access to the original methods that barBody may be overriding.

This commit turns the haskell-packages value into a "class".

The knot-tying, a.k.a the object instanitation, is moved into haskells-defaults.  The "finalReturn" is no longer needed and is eliminated from the body of
haskell-packages. All the work done by prefFun is moved to haskell-defaults, so that parameter is eliminated form haskell-packages.  Notice that the old prefFun took
two pameters named "self" and "super", but both parameters got passed the same value "result".  There seems to have been some confusion in the old code.

Inside haskell-defaults, the haskell-packages class is extended twice before instantiation.  The first extension is done using prefFun argument.
The second extension is done the extension argument, which is a renamed version of extraPrefs.

This two stage approach means that extension's super gets access to the post "perfFun" object while previously the extraPrefs only had access to the pre "prefFun"
object.  Also the extension function has access to both the super (post "perfFun") object and to self, the final object.  With extraPrefs, one needed to use the
"finalReturn" of the haskell packages to get access to the final object.  Due to significant changes in semantics, I thought it best to replace extraPrefs with
extension so that people using extraPrefs know to update thier cod.

Lastly, all the Prefs functions have renamed the "self" parameter to "super".  This is because "self" was never actually a self-reference in the object oriented sense
of the word.  For example

    Cabal_1_18_1_3 = self.Cabal_1_18_1_3.override { deepseq = self.deepseq_1_3_0_2; };

doesn't actually make sense from an object oriented standpoint because, barring further method overriding, the value of Cabal_1_18_1_3 would be trying to override it's
own value which simply causes a loop exception.  Thankfully all these uses of self were really uses of super:

    Cabal_1_18_1_3 = super.Cabal_1_18_1_3.override { deepseq = super.deepseq_1_3_0_2; };

In this notation the overriden Cabal_1_18_1_3 method calls the Cabal_1_18_1_3 of the super-class, which is a well-founded notion.

Below is an example use of using "extension" parameter

{
  packageOverrides = pkgs : {
    testHaskellPackages = pkgs.haskellPackages.override {
      extension = self : super : {
        transformers_0_4_1_0 = self.cabal.mkDerivation (pkgs: {
        pname = "transformers";
        version = "0.4.1.0";
        sha256 = "0jlnz86f87jndv4sifg1zpv5b2g2cxy1x2575x727az6vyaarwwg";
        meta = {
          description = "Concrete functor and monad transformers";
          license = pkgs.stdenv.lib.licenses.bsd3;
          platforms = pkgs.ghc.meta.platforms;
          maintainers = [ pkgs.stdenv.lib.maintainers.andres ];
        };
       });

      transformers = self.transformers_0_4_1_0;

      lensFamilyCore = super.lensFamilyCore.override { transformers = self.transformers_0_3_0_0; };
     };
   };
 };
}

Notice the use of self in the body of the override of the transformers method which references the newly defined transformers_0_4_1_0 method.

With the previous code, one would have to instead akwardly write

      transformers = super.finalReturn.transformers_0_4_1_0;

or use a rec clause, which would prevent futher overriding of transformers_0_4_1_0.
2014-05-08 12:01:45 -04:00
..
all-packages.nix The logic behind 'libiconvOrLibc' is flawed and that attribute should be removed. 2014-05-07 23:11:51 +02:00
guile-2-test.nix
haskell-defaults.nix Rework the knot-tying code for defining Haskell packages. 2014-05-08 12:01:45 -04:00
haskell-packages.nix Rework the knot-tying code for defining Haskell packages. 2014-05-08 12:01:45 -04:00
make-tarball.nix Tarball: Check whether Nixpkgs evaluation doesn't depend on its path 2014-04-20 00:08:52 +02:00
mingw.nix
node-packages-generated.nix node-packages: upgrade all generated expressions 2014-04-24 08:05:44 +02:00
node-packages.json Add remarkjs 0.6.4, a markdown-driven slideshow tool 2014-04-21 01:27:23 +02:00
node-packages.nix
perl-packages.nix perl-dbix-class: Fix tests with newer SQLite. 2014-04-22 16:27:28 +02:00
php-packages.nix re-introduce phpXdebug as phpPackages.xdebug and bump to 2.2.5 2014-05-07 14:18:18 +03:00
platforms.nix
python-packages-generated.nix python-suds: Add new package 2014-03-20 12:22:38 +01:00
python-packages.json python-suds: Add new package 2014-03-20 12:22:38 +01:00
python-packages.nix pythonPackages: add pyrax 2014-05-07 04:13:47 -05:00
release-cross.nix Use mingw-w64 for 32bit Windows builds as well. 2014-03-03 22:38:48 +01:00
release-lib.nix
release-python.nix get rid of old webkit and webkit_gtk2 packages 2014-03-30 09:02:07 +08:00
release-small.nix release: fix automake evaluation, broken in 5888f27c 2014-02-02 12:09:58 +01:00
release.nix Add some packages to the channel 2014-04-28 18:34:23 +02:00