Open fvilante opened 4 years ago
It's necessary to make this esier to do a type query on implementations. Bellow (type A
line) is an example of what we want to improve.
const fromMaybe: Future_['fromMaybe'] = ma => {
type A = Parameters<Parameters<ReturnType<typeof ma>['map']>[0]>[0] // <-- Should be easier
return Future_.fromResult<void,A>( () => Result.fromMaybe(ma()))
}
One idea is to define among the structure elements a element with allow to pick the type parameter gieven an instance of the Algebraic type. For example:
type __InspectorOfFuture<T extends Future<any,any>> = {
readonly E: ...
readonly A: ...
}
>99% type inference
I noticed that most of the time the above kind of patter (expressed as type A
) can be avoided with some code refactoring. I have a strong feeling that is it possible do have automatic inference in pratically all circunstances.
There's I way, to write a source into a file that seems so structured, reproductive and scalable. I'll monitor it here, to see if it can become something apt to the style guide
43