<commit_before>﻿using System;
using System.Collections.Immutable;
using Newtonsoft.Json;

namespace Bud {
  public class Macro : Plugin {
    public static readonly ConfigKey<ImmutableDictionary<string, Macro>> Macros = Key.Define("macros");
    public const string MacroNamePrefix = "@";

    public Macro(string name, Func<Settings, string[], Settings> function, string description = "")
      : this(name, (context, arguments) => new MacroResult(null, context.WithSettings(function(context.Settings, arguments))), description) {}

    public Macro(string name, MacroFunction function, string description = "") {
      Name = name;
      Function = function;
      Description = description;
    }

    public string Name { get; }

    [JsonIgnore]
    public MacroFunction Function { get; }

    public string Description { get; }

    public override Settings Setup(Settings settings) {
      return settings.AddGlobally(Macros.Init(ImmutableDictionary<string, Macro>.Empty),
                                  Macros.Modify(macros => macros.Add(Name, this)));
    }

    public static Macro Valued<T>(string name, Func<BuildContext, string[], T> function, string description = "") {
      return new Macro(name, (context, arguments) => new MacroResult(function(context, arguments), context), description);
    }

    public static Macro Valued<T>(string name, Func<Settings, string[], T> function, string description = "") {
      return new Macro(name, (context, arguments) => new MacroResult(function(context.Settings, arguments), context), description);
    }
  }
}<commit_msg>Removed an unused macro definition type.<commit_after>﻿using System;
using System.Collections.Immutable;
using Newtonsoft.Json;

namespace Bud {
  public class Macro : Plugin {
    public static readonly ConfigKey<ImmutableDictionary<string, Macro>> Macros = Key.Define("macros");
    public const string MacroNamePrefix = "@";

    public Macro(string name, Func<Settings, string[], Settings> function, string description = "")
      : this(name, (context, arguments) => new MacroResult(null, context.WithSettings(function(context.Settings, arguments))), description) {}

    public Macro(string name, MacroFunction function, string description = "") {
      Name = name;
      Function = function;
      Description = description;
    }

    public string Name { get; }

    [JsonIgnore]
    public MacroFunction Function { get; }

    public string Description { get; }

    public override Settings Setup(Settings settings) {
      return settings.AddGlobally(Macros.Init(ImmutableDictionary<string, Macro>.Empty),
                                  Macros.Modify(macros => macros.Add(Name, this)));
    }

    public static Macro Valued<T>(string name, Func<BuildContext, string[], T> function, string description = "") {
      return new Macro(name, (context, arguments) => new MacroResult(function(context, arguments), context), description);
    }
  }
}
{'fraction_non_alphanumeric': 0.11447010869565218, 'fraction_numerical': 0.0, 'mean_word_length': 3.9001663893510816, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '899056', 'n_tokens_mistral': 787, 'n_tokens_neox': 767, 'n_words': 222}