import { flow } from 'fp-ts/function' ; import { match , Option } from 'fp-ts/Option' ; interface User { readonly username : string ; } declare const queryByUsername ; interface Ok < A > { readonly code : 200 ; readonly body : A ; } interface NotFound { readonly code : 404 ; readonly message : string ; } type HttpResponse < A > = Ok < A > | NotFound ; const ok = < A > ( body ) : HttpResponse < A > => ( { code : 200 , body } ) ; const notFound = ( message ) : HttpResponse < never > => ( { code : 404 , message } ) ; export const getByUsername = flow ( queryByUsername , match ( ( ) => notFound ( 'User not found.' ) , ok ) ) ;