Skip to content

Commit

Permalink
lib.types: chore use consistent payload form
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjobeki committed Dec 9, 2024
1 parent fd6bc1b commit f407f6f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,10 @@ rec {
check = isString;
merge = loc: defs: concatStringsSep sep (getValues defs);
functor = (defaultFunctor name) // {
payload = sep;
binOp = sepLhs: sepRhs:
if sepLhs == sepRhs then sepLhs
payload = { inherit sep; };
type = payload: types.separatedString payload.sep;
binOp = lhs: rhs:
if lhs.sep == rhs.sep then { inherit (lhs) sep; }
else null;
};
};
Expand Down Expand Up @@ -1014,7 +1015,11 @@ rec {
else "conjunction";
check = flip elem values;
merge = mergeEqualOption;
functor = (defaultFunctor name) // { payload = values; binOp = a: b: unique (a ++ b); };
functor = (defaultFunctor name) // {
payload = { inherit values; };
type = payload: types.enum payload.values;
binOp = a: b: { values = unique (a.values ++ b.values); };
};
};

# Either value of type `t1` or `t2`.
Expand Down

0 comments on commit f407f6f

Please sign in to comment.