`and` matches
It looks like there's a start on first-order logic with or.
I'm wondering if there's any interest or past attempts at and. I have something sort of working but I'm not completely happy with it. It seems to recognize something like the following should not compile (very disorganized playground and pseudoish-code):
declare function isNumber = (x:unknown) => x is number
declare function isString = (x:unknown) => x is string
and(isNumber,isString)(42)
So maybe that's as far as we can go.
What I'd really think was cool is if we could inform the compiler the resultant type is the "intersection" of all the predicate arguments to and.
e.g.
const fooBarBaz: Foo & Bar & Baz = and(isFoo, isBar, isBaz)({a:1,b:2,c:3)
I've made a couple passes at implementing that. I'm guessing there's something I'm not understanding fully about x is Foo return types/existential predicates. It looks like the compiler infers them as booleans sometimes.
Further there might need to be an H list or equivalent to deal with the polymorphism of the predicate arguments.