package scotch.data.ratio; import static scotch.runtime.RuntimeSupport.applicable; import static scotch.runtime.RuntimeSupport.callable; import static scotch.symbol.type.TypeDescriptors.fn; import static scotch.symbol.type.TypeDescriptors.sum; import scotch.data.double_.Double_; import scotch.data.int_.Int; import scotch.runtime.Applicable; import scotch.symbol.Value; import scotch.symbol.ValueType; import scotch.symbol.type.TypeDescriptor; @SuppressWarnings("unused") public class RatioModule { @Value(memberName = "toDouble") public static Applicable<Ratio<Integer>, Double> toDouble() { return applicable(ratio -> callable(() -> ratio.call().getNumerator().call().doubleValue() / ratio.call().getDenominator().call().doubleValue())); } @ValueType(forMember = "toDouble") public static TypeDescriptor toDouble$type() { return fn(sum("scotch.data.ratio.Ratio", Int.TYPE), Double_.TYPE); } }