hegel
hegel copied to clipboard
Two generic functions
First of all thank you for such a great project. I really like it 👍
I was playing around generic function and found that this code show the error:
function id<T>(x: T): T {
return x
}
function composition<A, B, C>(
f: (p1: A) => B,
g: (p2: B) => C,
): (p: A) => C {
return (x: A) => g(f(x))
}
const a = (x: number) => x + 1
const comp = composition(a, id) // this function is ok
// but this one has an error
// Type "<T>(T) => T" is incompatible with type "<T>(T) => number"
const comp2 = composition(id, a)
I don't know if it is even a bug.
Oh, thank you a lot @polemius. We will fix it. You are awesome ^_^