query
On this page

defaultTypeMerge

lib.types.defaultTypeMerge

Docs pulled from | This Revision | 16 minutes ago


Nixpkgs manual

takes two type functors and return the merged type

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

defaultTypeMerge =
    f: f':
    let
      mergedPayload = f.binOp f.payload f'.payload;

      hasPayload =
        assert (f'.payload != null) == (f.payload != null);
        f.payload != null;
    in
    # Abort early: cannot merge different types
    if f.name != f'.name then
      null
    else

    if hasPayload then
      if mergedPayload == null then null else f.type mergedPayload
    else
      f.type;