Effect CommunityEC
Effect Community3y ago
47 replies
Jules

Seeking Advice on Defining types correctly

Hi everyone,

I'm not sure I'm doing things correctly/optimally
I'd like your advices

I define my types this way:
export const ApiKeyMetadataBrand = Symbol.for("ApiKeyMetadata")
export const ApiKeyMetadata = S.struct({
  name: ApiKeyName,
  createdAt: S.dateFromString(S.string),
  createdBy: GithubLogin,
  lastUsedAt: S.optional(S.dateFromString(S.string)).toOption(),
  identifier: NonEmptyString,
}).pipe(S.brand(ApiKeyMetadataBrand))
export type ApiKeyMetadata = S.To<typeof ApiKeyMetadata>


later in my code, I have HashMap<Project, Chunk<ApiKeyMetadata>> that I update with a new entry:
// this code doesn't have much importance for my issue. It's just to give you the context
const map: HashMap<Project, Chunk<ApiKeyMetadata>> = ...
const newMap = HasMap.modify(projectA, Chunk.append(metadata))(map)


(my message is too long, I need to cut it in two messages)
Was this page helpful?