concept Prop in category functional programming

This is an excerpt from Manning's book Functional Programming with Kotlin.
Here, we’ve simply invented a new type,
Prop(short for property) for the result of binding aGento a predicate. We might not know the internal representation ofPropor what other functions it supports, but based on our prior discussion in section 8.1, it should be combined with otherPropinstances through the use of anandmethod. Let’s introduce that as a new interface:interface Prop { fun and(p: Prop): Prop }
Assuming the following representation, use
checkto implementandas a method ofProp.interface Prop { fun check(): Boolean fun and(p: Prop): Prop = TODO() }In this representation,
Propis nothing more than a non-strictBoolean. Any of the usualBooleanfunctions (AND, OR, NOT, XOR, and so on) can easily be defined forProp. But aBooleanalone is probably insufficient. If a property fails, we might want to know how many tests succeeded first. We might also be interested in what arguments produced the failure. And if a property succeeds, it would be useful to know how many tests it ran. Next, let’s encode this information by returning anEitherto indicate success or failure:typealias SuccessCount = Int interface Prop { fun check(): Either<String, SuccessCount> fun and(p: Prop): Prop }For now, we’ve assigned the failure case to be
String, but what type should we return on the left side? We don’t know anything about the type of the test cases being generated. Should we add a type parameter toPropand make itProp<A>socheckcould returnEither<A, SuccessCount>. Before going too far down this route, let’s ask ourselves whether we really care about the type of the value that caused the property to fail. We don’t really. We would only care about the type if we were going to do further computation with the failure.