forked from baetheus/fun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofunctor.ts
More file actions
34 lines (31 loc) · 1.22 KB
/
profunctor.ts
File metadata and controls
34 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { $, Kind, TypeClass } from "./kind.ts";
/**
* Profunctor
* https://github.com/fantasyland/static-land/blob/master/docs/spec.md#profunctor
*
* TODO: Strong, Choice, Star, Join, and Split
*/
export interface Profunctor<U extends Kind> extends TypeClass<U> {
readonly dimap: <A, I, L, D>(
fld: (l: L) => D,
fai: (a: A) => I,
) => <B, C, E>(ta: $<U, [A, B, C], [D], [E]>) => $<U, [I, B, C], [L], [E]>;
}
// // TODO: fanout and splitStrong
// export interface Strong<U extends Kind> extends TypeClass<U>, Profunctor<U> {
// readonly first: <A, B, C, D, E, Q = never>(
// ua: $<U, [A, B, C], [D], [E]>,
// ) => $<U, [Pair<A, Q>, B, C], [Pair<D, Q>], [E]>;
// readonly second: <A, B, C, D, E, Q = never>(
// ua: $<U, [A, B, C], [D], [E]>,
// ) => $<U, [Pair<Q, A>, B, C], [Pair<Q, D>], [E]>;
// }
// // TODO: fanin and splitChoice
// export interface Choice<U extends Kind> extends TypeClass<U>, Profunctor<U> {
// readonly left: <A, B, C, D, E, Q = never>(
// ua: $<U, [A, B, C], [D], [E]>,
// ) => $<U, [Either<A, Q>, B, C], [Either<D, Q>], [E]>;
// readonly right: <A, B, C, D, E, Q = never>(
// ua: $<U, [A, B, C], [D], [E]>,
// ) => $<U, [Either<Q, A>, B, C], [Either<Q, D>], [E]>;
// }