import { FunctorParameter , GenericFunctor , InstanceFunctor , StaticFunctor } from "../../lib/abstract/functor" ; import { Either } from "../../lib/data/either" ; import { Option } from "../../lib/data/option" ; import { test } from "../../tests/harness" ; const instanceMap = < F extends InstanceFunctor < F > , B > ( fn , fa ) : GenericFunctor < F , B > => fa . map ( fn ) ; const staticMap = < F , B > ( f , fn , fa ) : GenericFunctor < F , B > => f . map ( fn , fa ) ; const toString = ( a ) => a . toString ( ) ; test ( "examples/abstract/functor1" , test => { test . plan ( 4 ) ; let option = new Option ( 4 ) ; let staticOption = Option ; let instanceOption = option ; test . deepEqual < Option < string > > ( option . map ( toString ) ) ( instanceMap ( toString , option ) ) ; test . deepEqual < Option < string > > ( option . map ( toString ) ) ( staticMap ( Option , toString , option ) ) ; test . deepEqual < Option < string > > ( option . map ( toString ) ) ( staticOption . map ( toString , option ) ) ; test . deepEqual < Option < string > > ( option . map ( toString ) ) ( instanceOption . map ( toString ) ) ; } ) ; test ( "examples/abstract/functor2" , test => { test . plan ( 4 ) ; let either = new Option ( 4 ) . toEither ( "error" ) ; let staticEither = Either ; let instanceEither = either ; test . deepEqual < Either < string , string > > ( either . map ( toString ) ) ( instanceMap ( toString , either ) ) ; test . deepEqual < Either < string , string > > ( either . map ( toString ) ) ( staticMap ( Either , toString , either ) ) ; test . deepEqual < Either < string , string > > ( either . map ( toString ) ) ( staticEither . map ( toString , either ) ) ; test . deepEqual < Either < string , string > > ( either . map ( toString ) ) ( instanceEither . map ( toString ) ) ; } ) ;