具有多个参数的组合

Composition with multiple params

我经常发现自己需要对具有多个参数的函数使用无点函数组合,方法如下:

compose2 :: ∀ a b c r. (c -> r) -> (a -> b -> c) -> a -> b -> r
compose2 g f a b = g (f a b)


compose3 :: ∀ a b c d r. (d -> r) -> (a -> b -> c -> d) -> a -> b -> c -> r
compose3 g f a b c = g (f a b c)

我没有看到直接提供此类方法的标准库,是否有其他更简单的方法来获得相同的结果?

Searching on Pursuit by your type signatures reveals a library called purescript-point-free 提供 compose2compose3,它们的运算符别名等等。