From 8331e78982ca0dc623e0d3eabfa23af30098aaed Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sat, 5 Jun 2021 19:36:12 +0200 Subject: [PATCH] Distribution.Nixpkgs.PackageMap: examples from doctest Since both haskell-ci (even with cabal-docspec) and doctest insist that there should be no way to skip even a single example in the documentation that may not be doctest-able because of impurities or requirements in terms of environment, we have to use code blocks instead of the more semantic example entries in haddock markup to prevent it from trying to invoke nix-instantiate in CI which won't work in an ubuntu docker container. In the future we may be able to skip the file altogether either via a patch to the generated output or whatever resolves this issue: https://github.com/haskell-CI/haskell-ci/issues/519 --- src/Distribution/Nixpkgs/PackageMap.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Distribution/Nixpkgs/PackageMap.hs b/src/Distribution/Nixpkgs/PackageMap.hs index c905472..08b7c4a 100644 --- a/src/Distribution/Nixpkgs/PackageMap.hs +++ b/src/Distribution/Nixpkgs/PackageMap.hs @@ -28,8 +28,10 @@ type PackageMap = Map Identifier (Set Path) -- Note: Evaluation of nixpkgs is very expensive (takes multiple -- seconds), so cache the result of this function if possible. -- --- >>> readNixpkgPackageMap "" (Just "{ config = { allowAliases = false; }; }") +-- @ +-- >>> readNixpkgPackageMap "\" (Just "{ config = { allowAliases = false; }; }") -- fromList [ … ] +-- @ readNixpkgPackageMap :: String -- ^ Path to nixpkgs, must be a valid nix path -- (absolute, relative or @NIX_PATH@ lookup) @@ -77,8 +79,10 @@ parsePackage x -- | Finds the shortest 'Path' in a 'PackageMap' that has the -- given 'Identifier' as its last component. -- +-- @ -- >>> resolve nixpkgs (ident # "pam") -- Just (Bind (Identifier "pam") (Path [Identifier "pam"])) +-- @ resolve :: PackageMap -> Identifier -> Maybe Binding resolve nixpkgs i = case Map.lookup i nixpkgs of Nothing -> Nothing