import "./builtins" ; import { Of , Generic , Repr } from "tshkt" ; import { Identity } from "./Identity" ; interface Functor < F > { map < A , B > ( fa , f ) : Of < F , B > ; } function map < F , A , B > ( functor , fa , f ) { return functor . map ( fa , f ) ; } function asVoid < F , A > ( functor , fa ) { return map ( functor , fa , ( ) => { } ) ; } function dupAndShow < F , A > ( F , fa ) { return F . map ( F . map ( fa , x => [ x , x ] as const ) , ( [ a , b ] ) => [ a , String ( b ) ] as const ) ; } const ArrayFunctor = { map < A , B > ( fa , f ) { return fa . map ( f ) ; } } ; const IdentityFunctor = { map < A , B > ( fa , f ) { return new Identity ( f ( fa . get ( ) ) ) ; } } ; dupAndShow ( ArrayFunctor , [ 1 , 2 , 3 ] ) ; asVoid ( IdentityFunctor , dupAndShow ( IdentityFunctor , new Identity ( 2 ) ) ) ;