Questions about `Unify<T>` HKT and Pattern Matching

Couple of questions about the Unify<T> HKT:
1) For any type T, Can you assume that Unify<T> extends T (like can I always just do as T to get rid of it?)
2) If I build a simple pattern matcher like this:
// model
export interface A {
  readonly _tag: "A";
  ...
}
export interface B {
  readonly _tag: "B";
  ...
}

export type U = A | B;

// matchers
export const match = <T,>(handlers: {
  onA: (a: A) => T;
  onB: (b: B) => T;
}) =>
  pipe(
    Match.type<U>(),
    Match.tag("a", (a) => handlers.onA(a) as T),
    Match.tag("b", (b) => handlers.onB(b) as T),
    Match.exhaustive
  ); // has return type (u : U) => Unify<T>, but I can add "as (v : Vector2D) => T" here and it seems to work

It says that the return type is Unify<T> , and it seems to compile if I add the thing in the comment, but I'm wondering if there is a cleaner way to make the function return T instead of Unify<T>? (if there is some documentation on unify, i would love to know as well, all i could find was the type definition itself)

(really cool library btw)
Was this page helpful?