# Haskell High-Order Function Composition ## Metadata **Status**:: #x **Zettel**:: #zettel/fleeting **Created**:: [[2026-01-30]] **Parent**:: [[Haskell]] ## Synopsis This is the prototype of `(.)` ```haskell (.) :: (b -> c) -> (a -> b) -> a -> c ``` Given a function `f :: b->c` and `g :: a->b`, `f . g` creates a composition that: ```haskell f . g $ x == f (g x) ``` Things become complex to compose high order functions. If g has the type `a->x->y`, the part that matches `b` is `x->y`, It turns out that `f` must accept a function `x->y` as the argument. ```haskell ((.negate) . (+)) 5 3 -- 2 ((negate.) . (+)) 5 3 -- -8 ``` - `(.negate) f x == f (negate x)` - `((.negate) . (+)) a b` - `==((.negate) (a+)) b` - `==((a+) . negate) b` - `==a-b And the second form will negate the return value of `+` - `(negate.) f x == negate (f x)` - `((negate.) . (+)) a b` - `==((negate.) (a+)) b` - `==(negate . (a+)) b - `==-(a+b)