since import { Eq } from 'fp-ts/lib/Eq' ; import { Functor } from 'fp-ts/lib/Functor' ; import { HKT } from 'fp-ts/lib/HKT' ; import { Apply } from 'fp-ts/lib/Apply' ; import { Chain } from 'fp-ts/lib/Chain' ; import { Applicative } from 'fp-ts/lib/Applicative' ; import { Monad } from 'fp-ts/lib/Monad' ; import { Ord } from 'fp-ts/lib/Ord' ; import { Semigroup } from 'fp-ts/lib/Semigroup' ; import { Monoid } from 'fp-ts/lib/Monoid' ; import { Semiring } from 'fp-ts/lib/Semiring' ; import { Ring } from 'fp-ts/lib/Ring' ; import { Field } from 'fp-ts/lib/Field' ; import { FunctionN } from 'fp-ts/lib/function' ; since export const eq = { reflexivity : < A > ( E ) => ( a ) : boolean => { return E . equals ( a , a ) ; } , simmetry : < A > ( E ) => ( a , b ) : boolean => { return E . equals ( a , b ) === E . equals ( b , a ) ; } , transitivity : < A > ( E ) => ( a , b , c ) : boolean => { return ( E . equals ( a , b ) && E . equals ( b , c ) ) === ( E . equals ( a , b ) && E . equals ( a , c ) ) ; } } ; since export const ord = { totality : < A > ( O ) => ( a , b ) : boolean => { return O . compare ( a , b ) <= 0 || O . compare ( b , a ) <= 0 ; } , reflexivity : < A > ( O ) => ( a ) : boolean => { return O . compare ( a , a ) <= 0 ; } , antisimmetry : < A > ( O ) => ( a , b ) : boolean => { return ( O . compare ( a , b ) <= 0 && O . compare ( b , a ) <= 0 ) === O . equals ( a , b ) ; } , transitivity : < A > ( O ) => ( a , b , c ) : boolean => { return ! ( O . compare ( a , b ) <= 0 && O . compare ( b , c ) <= 0 ) || O . compare ( a , c ) <= 0 ; } } ; since export const semigroup = { associativity : < A > ( S , E ) => ( a , b , c ) : boolean => { return E . equals ( S . concat ( S . concat ( a , b ) , c ) , S . concat ( a , S . concat ( b , c ) ) ) ; } } ; since export const monoid = { rightIdentity : < A > ( M , E ) => ( a ) : boolean => { return E . equals ( M . concat ( a , M . empty ) , a ) ; } , leftIdentity : < A > ( M , E ) => ( a ) : boolean => { return E . equals ( M . concat ( M . empty , a ) , a ) ; } } ; const allEquals = < A > ( E ) => ( a , ... as ) : boolean => { return as . every ( item => E . equals ( item , a ) ) ; } ; since export const semiring = { addAssociativity : < A > ( S , E ) => ( a , b , c ) : boolean => { return E . equals ( S . add ( S . add ( a , b ) , c ) , S . add ( a , S . add ( b , c ) ) ) ; } , addIdentity : < A > ( S , E ) => ( a ) : boolean => { return allEquals ( E ) ( a , S . add ( a , S . zero ) , S . add ( S . zero , a ) ) ; } , commutativity : < A > ( S , E ) => ( a , b ) : boolean => { return E . equals ( S . add ( a , b ) , S . add ( b , a ) ) ; } , mulAssociativity : < A > ( S , E ) => ( a , b , c ) : boolean => { return E . equals ( S . mul ( S . mul ( a , b ) , c ) , S . mul ( a , S . mul ( b , c ) ) ) ; } , mulIdentity : < A > ( S , E ) => ( a ) : boolean => { return allEquals ( E ) ( a , S . mul ( a , S . one ) , S . mul ( S . one , a ) ) ; } , leftDistributivity : < A > ( S , E ) => ( a , b , c ) : boolean => { return E . equals ( S . mul ( a , S . add ( b , c ) ) , S . add ( S . mul ( a , b ) , S . mul ( a , c ) ) ) ; } , rightDistributivity : < A > ( S , E ) => ( a , b , c ) : boolean => { return E . equals ( S . mul ( S . add ( a , b ) , c ) , S . add ( S . mul ( a , c ) , S . mul ( b , c ) ) ) ; } , annihilation : < A > ( S , E ) => ( a ) : boolean => { return allEquals ( E ) ( S . zero , S . mul ( a , S . zero ) , S . mul ( S . zero , a ) ) ; } } ; since export const ring = { additiveInverse : < A > ( R , E ) => ( a ) : boolean => { return allEquals ( E ) ( R . sub ( a , a ) , R . add ( R . sub ( R . zero , a ) , a ) , R . zero ) ; } } ; since export const field = { commutativity : < A > ( F , S ) => ( a , b ) : boolean => { return S . equals ( F . mul ( a , b ) , F . mul ( b , a ) ) ; } , integralDomain : < A > ( F , S ) => ( a , b ) : boolean => { return S . equals ( a , F . zero ) || S . equals ( b , F . zero ) || ! S . equals ( F . mul ( a , b ) , F . zero ) ; } , nonNegativity : < A > ( F , S ) => ( a ) : boolean => { return S . equals ( a , F . zero ) || F . degree ( a ) >= 0 ; } , quotient : < A > ( F , S ) => ( a , b ) : boolean => { const q = F . div ( a , b ) ; const r = F . mod ( a , b ) ; return S . equals ( b , F . zero ) || S . equals ( a , F . add ( F . mul ( q , b ) , r ) ) ; } , reminder : < A > ( F , S ) => ( a , b ) : boolean => { const r = F . mod ( a , b ) ; return S . equals ( b , F . zero ) || S . equals ( r , F . zero ) || F . degree ( a ) <= F . degree ( b ) ; } , submultiplicative : < A > ( F , S ) => ( a , b ) : boolean => { return S . equals ( a , F . zero ) || S . equals ( b , F . zero ) || F . degree ( a ) <= F . degree ( F . mul ( a , b ) ) ; } , inverse : < A > ( F , S ) => ( a ) : boolean => { const i = F . div ( F . one , a ) ; return S . equals ( a , F . zero ) || allEquals ( S ) ( F . one , F . mul ( i , a ) , F . mul ( a , i ) ) ; } } ; since export const functor = { identity : < F , A > ( F , S ) => ( fa ) : boolean => { return S . equals ( F . map ( fa , a => a ) , fa ) ; } , composition : < F , A , B , C > ( F , S , ab , bc ) => ( fa ) : boolean => { return S . equals ( F . map ( fa , a => bc ( ab ( a ) ) ) , F . map ( F . map ( fa , ab ) , bc ) ) ; } } ; since export const apply = { associativeComposition : < F , A , B , C > ( F , S ) => ( fa , fab , fbc ) : boolean => { return S . equals ( F . ap ( F . ap ( F . map ( fbc , bc => ( ab ) => ( a ) => bc ( ab ( a ) ) ) , fab ) , fa ) , F . ap ( fbc , F . ap ( fab , fa ) ) ) ; } } ; since export const applicative = { identity : < F , A > ( F , S ) => ( fa ) : boolean => { return S . equals ( F . ap ( F . of ( ( a ) => a ) , fa ) , fa ) ; } , homomorphism : < F , A , B > ( F , S , ab ) => ( a ) : boolean => { return S . equals ( F . ap ( F . of ( ab ) , F . of ( a ) ) , F . of ( ab ( a ) ) ) ; } , interchange : < F , A , B > ( F , S ) => ( a , fab ) : boolean => { return S . equals ( F . ap ( fab , F . of ( a ) ) , F . ap ( F . of ( ( ab ) => ab ( a ) ) , fab ) ) ; } , derivedMap : < F , A , B > ( F , S , ab ) => ( fa ) : boolean => { return S . equals ( F . map ( fa , ab ) , F . ap ( F . of ( ab ) , fa ) ) ; } } ; since export const chain = { associativity : < F , A , B , C > ( F , S , afb , bfc ) => ( fa ) : boolean => { return S . equals ( F . chain ( F . chain ( fa , afb ) , bfc ) , F . chain ( fa , a => F . chain ( afb ( a ) , bfc ) ) ) ; } , derivedAp : < F , A , B > ( F , S , fab ) => ( fa ) : boolean => { return S . equals ( F . ap ( fab , fa ) , F . chain ( fab , f => F . map ( fa , f ) ) ) ; } } ; since export const monad = { leftIdentity : < M , A , B > ( M , S , afb ) => ( a ) : boolean => { return S . equals ( M . chain ( M . of ( a ) , afb ) , afb ( a ) ) ; } , rightIdentity : < M , A > ( M , S ) => ( fa ) : boolean => { return S . equals ( M . chain ( fa , M . of ) , fa ) ; } , derivedMap : < M , A , B > ( M , S , ab ) => ( fa ) : boolean => { return S . equals ( M . map ( fa , ab ) , M . chain ( fa , a => M . of ( ab ( a ) ) ) ) ; } } ;