Class FunHelper

java.lang.Object
org.kink_lang.kink.FunHelper

public class FunHelper extends Object
A helper for funs.
  • Method Details

    • compile

      public <T> T compile(Locale locale, String programName, String programText, BindingVal binding, Function<? super FunVal,? extends T> onSucc, Function<? super CompileError,? extends T> onError)
      Compiles a program text to a top level fun.

      If the program text is successfully compiled to a top level fun, onSucc is called with the fun.

      If the program text cannot be compiled and causes a compile error, onError is called with the compile error.

      Type Parameters:
      T - the type of the result.
      Parameters:
      locale - the locale to generate compile error messages.
      programName - the name of the program.
      programText - the program text.
      binding - the binding of the top level fun.
      onSucc - the function which is called when the program is successfully compiled.
      onError - the function which is called when the program causes a compile error.
      Returns:
      the result of onSucc or onError.
    • make

      public HostFunBuilder make()
      Returns a builder of a host fun.

      Calling this method is equivalent to calling make("(fun)").

      See org.kink_lang.kink.hostfun for detail.

      Returns:
      a builder.
    • make

      public HostFunBuilder make(String desc)
      Returns a builder of a host fun, with the description of the fun.

      See org.kink_lang.kink.hostfun for detail.

      Parameters:
      desc - the description of the fun, which is used in arity error messages.
      Returns:
      a builder.
    • constant

      public FunVal constant(Val val)
      Returns a constant fun: which is a 0-ary fun returning the val constantly.
      Parameters:
      val - the constant val.
      Returns:
      a constant fun.