@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
34 lines (29 loc) • 560 B
Flow
// @flow
import type { Setoid } from './Setoid'
import type { Semigroup } from './Semigroup'
export type Ordering = 'LT' | 'EQ' | 'GT';
export const orderingSetoid: Setoid<Ordering> = {
equals(a, b) {
return a === b
}
}
export const orderingSemigroup: Semigroup<Ordering> = {
concat(a, b) {
if (a === 'LT') {
return 'LT'
}
if (a === 'GT') {
return 'GT'
}
return b
}
}
export function invert(a: Ordering): Ordering {
if (a === 'LT') {
return 'GT'
}
if (a === 'GT') {
return 'LT'
}
return 'EQ'
}