Skip to content

Instantly share code, notes, and snippets.

@kalda341
Created November 16, 2021 20:52
Show Gist options
  • Save kalda341/f4149edc894aec8c06cbe93d425fe394 to your computer and use it in GitHub Desktop.
Save kalda341/f4149edc894aec8c06cbe93d425fe394 to your computer and use it in GitHub Desktop.
const eqString = Eq.fromEquals<string>((x, y) => x === y);
interface Animal {
name: string;
}
interface SingleAnimalZoo {
animal: Animal;
}
const eqZoo: Eq.Eq<SingleAnimalZoo> = F.pipe(
eqString,
Eq.contramap((animal: Animal): string => animal.name),
Eq.contramap((zoo: SingleAnimalZoo) => zoo.animal)
);
const eqAnimal = Eq.fromEquals<Animal>((x, y) =>
eqString.equals(x.name, y.name)
);
eqString.equals('a', 'b'); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment