package scotch.data.floating; import static java.util.Arrays.asList; import static scotch.runtime.RuntimeSupport.applicable; import static scotch.runtime.RuntimeSupport.flatCallable; import static scotch.symbol.Value.Fixity.RIGHT_INFIX; import static scotch.symbol.type.TypeDescriptors.fn; import static scotch.symbol.type.TypeDescriptors.var; import scotch.data.fractional.Fractional; import scotch.data.num.Num; import scotch.runtime.Applicable; import scotch.runtime.Callable; import scotch.symbol.TypeClass; import scotch.symbol.TypeParameter; import scotch.symbol.Value; import scotch.symbol.ValueType; import scotch.symbol.type.TypeDescriptor; @SuppressWarnings("unused") @TypeClass(memberName = "Floating", parameters = { @TypeParameter(name = "a", constraints = { "scotch.data.fractional.Fractional", "scotch.data.num.Num", }), }) public interface Floating<A> { TypeDescriptor a = var("a", asList("scotch.data.floating.Floating", "scotch.data.fractional.Fractional", "scotch.data.num.Num")); @Value(memberName = "**", fixity = RIGHT_INFIX, precedence = 8) static <A> Applicable<Floating<A>, Applicable<Fractional<A>, Applicable<Num<A>, Applicable<A, Applicable<A, A>>>>> pow() { return applicable(floating -> applicable(fractional -> applicable(num -> applicable(left -> applicable(right -> flatCallable(() -> floating.call().pow(fractional, num, left, right))))))); } @ValueType(forMember = "**") static TypeDescriptor pow$type() { return fn(a, fn(a, a)); } @Value(memberName = "sqrt") static <A> Applicable<Floating<A>, Applicable<Fractional<A>, Applicable<Num<A>, Applicable<A, A>>>> sqrt() { return applicable(floating -> applicable(fractional -> applicable(num -> applicable(operand -> flatCallable(() -> floating.call().sqrt(fractional, num, operand)))))); } @ValueType(forMember = "sqrt") static TypeDescriptor sqrt$type() { return fn(a, a); } Callable<A> pow(Callable<Fractional<A>> fractional, Callable<Num<A>> num, Callable<A> left, Callable<A> right); Callable<A> sqrt(Callable<Fractional<A>> fractional, Callable<Num<A>> num, Callable<A> operand); }