Effect CommunityEC
Effect Community3y ago
8 replies
steida

Refactoring Evolu: Serializing SqliteQuery as a Key in Sets and Maps

Hi, I'm refactoring Evolu, and I have this type:

export interface SqliteQuery {
  readonly sql: string;
  readonly parameters: ReadonlyArray<Value>;
}

export type Value = SqliteValue | JsonObjectOrArray;

export type SqliteValue = null | string | number | Uint8Array;

export type JsonObjectOrArray = JsonObject | JsonArray;

type JsonObject = ReadonlyRecord.ReadonlyRecord<Json>;
type JsonArray = ReadonlyArray<Json>;
type Json = string | number | boolean | null | JsonObject | JsonArray;


I'm using SqliteQuery as a key in sets and maps. I was serializing it as a string, but that should not be necessary with the Effect data type(s).

Should I define SqliteQuery as Data.Case? Or should I write custom Equivalence or Hash? What would you do? Thank you.
Was this page helpful?