/**
* Constrained isomorphisms. Compatible with `Iso` found in `monocle-ts`.
*
* @since 1.0.0
*/
import { flow, identity as id } from 'fp-ts/function'
// ###################
// ### Typeclasses ###
// ###################
/**
* @since 1.0.0
* @category Typeclasses
*/
export interface Iso {
get: (a: A) => B
reverseGet: (b: B) => A
}
// #################
// ### Instances ###
// #################
/**
* @since 1.0.0
* @category Instance Operations
*/
export const compose: (a: Iso, b: Iso) => Iso = (a, b) => ({
get: flow(a.get, b.get),
reverseGet: flow(b.reverseGet, a.reverseGet),
})
/**
* @since 1.0.0
* @category Instance Operations
*/
export const identity: () => Iso = () => ({
get: id,
reverseGet: id,
})