Effect CommunityEC
Effect Community2y ago
8 replies
Stephen Bluck

Transforming Array<Identity> to Record<Type, Option.Option<Identity>>

Anyone got any smart ways to transform an Array<Identity> -> Identites which is a Record<Type, Option.Option<Identity>>

export type Identity = Data.TaggedEnum<{
  EmailPassword: { email: string };
  Google: { email: string };
  Apple: { email: string };
}>;

// EmailPassword | Google | Apple
export type Type = Identity["_tag"];

export type Identities = Record<Type, Option.Option<Identity>>;

const data = [EmailPassword({ email: "" }), Google({ email: "" })];
Was this page helpful?