anchor.diff:  
     # to be used with listToAttrs (_a_ttribute _v_alue)
     av = attr : value : { inherit attr value; };
  +  # attribute set containing one attribute
  +  avs = attr : value : listToAttrs [ (av attr value) ];
  +  # adds / replaces an attribute of an attribute set
  +  setAttr = set : attr : v : set // (avs attr v);
   
     id = x : x;
     # true if all/ at least one element(s) satisfy f
  
positive.code: 
    # resolves chosen flags based on flagDescr passed dependencies in args
    # flagDescr : { name = { cfgOption = "..."; buildInputs = "..."; blocks = "..."; implies = "..."; 
    #                        assert = "bool";
    #                        any other options you need which you can get by catAttrs  };
    #              ...
    # args = { inherit lib stdenv;
  
negative.code:   # iterates over a list of attributes collecting the attribute attr if it exists
    catAttrs = attr : l : fold ( s : l : if (__hasAttr attr s) then [(__getAttr attr s)] ++ l else l) [] l;
  
    mergeAttrs = fold ( x : y : x // y) {};
  
    flattenAttrs = set : map ( attr : __getAttr attr set) (__attrNames set);
    mapIf = cond : f :  fold ( x : l : if (cond x) then [(f x)] ++ l else l) [];
  
  # Marc 2nd proposal: (not everything has been tested in detail yet..)
  # One example showing how to use mandatory dependencies [1], default flags [2], settings if a flag is not set [3] ..
  # 
  # note that you should be able to use either ["value1"] or just "value" .. (if I haven't forgotten a flatten)
  # linuxthreads
  
  #    args: with args.lib; with args;
  #    let
  #      co = chooseOptionsByFlags {
  #        inherit args;
  #        flagDescr = {
  #          defaults = { implies   = [ "addOns" "addOns2"]; }; # [2] defaults and mandatory should be the first listed ? Would you like it different?
  #          mandatory ={ cfgOption = [ "--with-headers=${args.kernelHeaders}/include" # [1]
  #                                      "--with-tls" "--without-__thread" "--disable-sanity-checks" ];
  #                       assertion = [ args.glibc.nptl ];
  #                     };
  #          defaultFeature    = {};
  #          no_defaultFeature = { cfgOption = "--disable-defaultFeature"; }; [3]
  #          addOns            = { cfgOption = "--enable-add-ons"; };
  #          addOns2           = { cfgOption = "--enable-add-ons2"; implies = "addOns"; };
  #          alternativeAddOn  = { cfgOption = "--enable-add-ons-alt"; blocks = ["addOns", "addOns2"]; };
  #          justAOption =  { };
  #        };
  #        optionals = ["option1" "option2"]; # are equal to a given flag description like option1 = { buildInputs = "option1"; };
  #        defaultFlags = [ "demos" "doc" ]; # are used if flags is not set by args
  #      };
  #
  #    in args.stdenv.mkDerivation ( {
  #
  #      # passing the flags in case a library using this want's to check them (*) .. 
  #      inherit (co) flags buildInputs configureFlags;
  #      inherit (co.flags) justAOption;
  #
  #      extraSrc = (if co.flags.justAOption then null else src = .. );
  #
  #      src = fetchurl {
  #        url = http://ftp.gnu.org/gnu/glibc/glibc-2.5.tar.bz2;
  #        md5 = "1fb29764a6a650a4d5b409dda227ac9f";
  #      };
  #    } // co.pass)
  
      # (*) does'nt work because nix is seeing this set as derivation and complains about missing outpath.. :-(
      # using mkDerivation { ...  } // oc.flags would work but would also force evaluation.. ( would be slower )
  