Commit Graph

16 Commits

Author SHA1 Message Date
Alexander Groleau
b7e69faf1d
lib/fixed-points.nix: correct typo
Corrects a minor typo in the description of `fix`; namely that `fix` allows factoring out syntactic recursion from another function.
2023-10-31 11:45:51 -07:00
Silvan Mosberger
b82c1c7b5c lib.fix: Improve doc more
Done together in and after the docs team meeting

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-10-12 17:38:00 +02:00
Robert Hensing
1f8b5c039e lib.fix: Improve doc
The original doc did not help with understanding at all, and the
wikipedia link was actively harmful.
2023-07-08 20:09:24 +02:00
Robert Hensing
aa1beb0ab5 doc: Render lib.fixedPoints 2023-07-08 18:46:08 +02:00
Chris Hodapp
06f0e49dc6 lib: make extender available on self-references 2023-01-15 11:34:05 -08:00
Shea Levy
d09222e48f
lib.compose{Many,}Extensions: Make compatible with nix flake check 2021-08-26 09:12:17 -04:00
Joe Hermaszewski
c3b35f21f7 lib: Add composeManyExtensions 2020-11-13 21:37:57 +01:00
Alyssa Ross
7ed977e60d
lib.converge: optimise 2019-04-17 15:55:57 +01:00
Alyssa Ross
67b1265fb3
bundlerEnv: ensure dependencies always included
Suppose I have a Gemfile like this:

    source "https://rubygems.org"
    gem "actioncable"
    gem "websocket-driver", group: :test

The gemset.nix generated by Bundix 2.4.1 will set ActionCable's groups
to [ "default" ], and websocket-driver's to [ "test" ]. This means that
the generated bundlerEnv wouldn't include websocket-driver unless the
test group was included, even though it's required by the default group.

This is arguably a bug in Bundix (websocket-driver's groups should
probably be [ "default" "test" ] or just [ "default" ]), but there's no
reason bundlerEnv should omit dependencies even given such an input --
it won't necessarily come from Bundix, and it would be good for
bundlerEnv to do the right thing.

To fix this, filterGemset is now a recursive function, that adds
dependencies of gems in the group to the filtered gemset until it
stabilises on the gems that match the required groups, and all of their
recursive dependencies.
2018-12-11 21:26:07 +00:00
Eric Wolf
3cc83dffca lib/fixed-points.nix: add an example for extends
- helped me understand how extends works, hopefully it can help others too
2018-11-21 17:40:20 +01:00
Shea Levy
1a1ad1a17d Revert "Merge branch 'improved-make-overridable' of git://github.com/ElvishJerricco/nixpkgs"
This reverts commit c3af1210b4, reversing
changes made to 49f175cd0c.
2017-09-29 09:11:26 -04:00
Shea Levy
c3af1210b4 Merge branch 'improved-make-overridable' of git://github.com/ElvishJerricco/nixpkgs 2017-09-28 18:10:50 -04:00
Graham Christensen
152c63c9ff
Convert libs to a fixed-point
This does break the API of being able to import any lib file and get
its libs, however I'm not sure people did this.

I made this while exploring being able to swap out docFn with a stub
in #2305, to avoid functor performance problems. I don't know if that
is going to move forward (or if it is a problem or not,) but after
doing all this work figured I'd put it up anyway :)

Two notable advantages to this approach:

1. when a lib inherits another lib's functions, it doesn't
   automatically get put in to the scope of lib
2. when a lib implements a new obscure functions, it doesn't
   automatically get put in to the scope of lib

Using the test script (later in this commit) I got the following diff
on the API:

  + diff master fixed-lib
  11764a11765,11766
  > .types.defaultFunctor
  > .types.defaultTypeMerge
  11774a11777,11778
  > .types.isOptionType
  > .types.isType
  11781a11786
  > .types.mkOptionType
  11788a11794
  > .types.setType
  11795a11802
  > .types.types

This means that this commit _adds_ to the API, however I can't find a
way to fix these last remaining discrepancies. At least none are
_removed_.

Test script (run with nix-repl in the PATH):

  #!/bin/sh

  set -eux

  repl() {
      suff=${1:-}
      echo "(import ./lib)$suff" \
          | nix-repl 2>&1
  }

  attrs_to_check() {
      repl "${1:-}" \
          | tr ';'  $'\n' \
          | grep "\.\.\." \
          | cut -d' ' -f2 \
          | sed -e "s/^/${1:-}./" \
          | sort
  }

  summ() {
      repl "${1:-}" \
          | tr ' ' $'\n' \
          | sort \
          | uniq
  }

  deep_summ() {
      suff="${1:-}"
      depth="${2:-4}"
      depth=$((depth - 1))
      summ "$suff"

      for attr in $(attrs_to_check "$suff" | grep -v "types.types"); do
          if [ $depth -eq 0 ]; then
              summ "$attr" | sed -e "s/^/$attr./"
          else
              deep_summ "$attr" "$depth" | sed -e "s/^/$attr./"
          fi
      done
  }

  (
      cd nixpkgs

      #git add .
      #git commit -m "Auto-commit, sorry" || true
      git checkout fixed-lib
      deep_summ > ../fixed-lib
      git checkout master
      deep_summ > ../master
  )

  if diff master fixed-lib; then
      echo "SHALLOW MATCH!"
  fi

  (
      cd nixpkgs
      git checkout fixed-lib
      repl .types
  )
2017-09-16 21:36:43 -04:00
Will Fancher
05f9db601a Added self views of the interface in makeExtensibleWithInterface
Fixing the `overrideScope` in `haskellpackages`.
2017-07-14 06:43:33 -04:00
Will Fancher
08021dd825 Added makeExtensibleWithInterface 2017-07-12 18:35:22 -04:00
John Ericson
87b4a91fc4 lib: Move fixed-point combinators out of trivial
Trivia != prelude. This is a better organized and less likely to
scare off new contributors.
2017-05-29 18:09:52 -04:00