fake.modules transposition for aspect-oriented Dendritic Nix. with cross-aspect dependencies. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic nix aspect oriented

improve heuristic for detecting if curried (#36)

* improve heuristic for detecting if curried

This adds a check that ensures it is either a native function or an
attribute set that only has __functor and/or __functionArgs attributes

* add tests for provides with functors

authored by

musjj and committed by
GitHub
d9502aba 88bac0fd

+38 -1
+33
checkmate/modules/tests/aspect_provides_functor.nix
··· 1 + { 2 + mkFlake, 3 + evalMod, 4 + ... 5 + }: 6 + { 7 + 8 + flake.tests."test provides with functors" = 9 + let 10 + flake = mkFlake { 11 + flake.aspects = 12 + { aspects, ... }: 13 + { 14 + aspectOne = { 15 + includes = [ aspects.aspectTwo._.aspectThree._.aspectFour ]; 16 + classOne = { }; 17 + }; 18 + aspectTwo.provides.aspectThree = { 19 + provides.aspectFour.classOne.bar = [ "hello" ]; 20 + __functor = self: _: self; 21 + }; 22 + }; 23 + }; 24 + 25 + expr = (evalMod "classOne" flake.modules.classOne.aspectOne).bar; 26 + expected = [ 27 + "hello" 28 + ]; 29 + in 30 + builtins.trace expr { 31 + inherit expr expected; 32 + }; 33 + }
+5 -1
nix/types.nix
··· 46 46 directProviderFn = lib.types.addCheck (lib.types.functionTo aspectSubmodule) isProviderFn; 47 47 48 48 # Curried provider function: (params) → provider (enables parametrization) 49 - curriedProviderFn = lib.types.functionTo providerType; 49 + curriedProviderFn = lib.types.addCheck (lib.types.functionTo providerType) ( 50 + f: 51 + builtins.isFunction f 52 + || lib.isAttrs f && lib.subtractLists [ "__functor" "__functionArgs" ] (lib.attrNames f) == [ ] 53 + ); 50 54 51 55 # Any provider function: direct or curried 52 56 providerFn = lib.types.either directProviderFn curriedProviderFn;