UNPKG

funfix-types

Version:

Sub-package of Funfix defining type classes inspired by Haskell's standard library

45 lines (36 loc) 1.21 kB
/*! * Copyright (c) 2017 by The Funfix Project Developers. * Some rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* @flow */ export type Constructor<T> = Class<T> | { +_funErasure: T } export type TypeClass<F> = Constructor<F> & { +_funTypeId: string; +_funSupertypeIds: string[]; } export interface HK<F, A> { +_funKindF: F; +_funKindA: A; } declare export class Equiv<A> { +lh: A; +rh: A; static of<A>(lh: A, rh: A): Equiv<A>; } declare export function registerTypeClassInstance<F>(tc: TypeClass<F>): <T>(c: Constructor<T>, instance: F) => void; declare export function getTypeClassInstance<F>(tc: TypeClass<F>): <T>(c: Constructor<T>) => F;