1

以下对 compose 函数的 Hindley-Milner 类型签名的尝试是否正确?

// compose :: (f -> [f]) -> (f -> f -> f) -> [f] -> f
const compose = (...fns) => fns.reduce((f,g) => (...args) => f(g(...args)));
4

2 回答 2

5
于 2017-10-27T19:57:00.393 回答
3

二元函数组合的类型更容易用 Hindley-Milner 表示法表示:

//    compose :: (b -> c) -> (a -> b) -> a -> c
const compose = f => g => x => f (g (x));
于 2019-03-16T22:59:52.493 回答