Or I'm misunderstanding the question. (In which case, please, somebody correct me.)
But if I'm not... Elm, Haskell, F#, and probably most other FP langs support this.
Or I'm misunderstanding the question. (In which case, please, somebody correct me.)
But if I'm not... Elm, Haskell, F#, and probably most other FP langs support this.
What I specifically meant by "(A -> B, B -> C)" was "two arguments, each of which are unary functions, and the type of the argument accepted by the second function is the same as the the return type of the first function." I think in formal notation, the full signature would be "(a -> b) -> (b -> c) -> (a -> c)" but I'm not overly familiar with that notation so I may have gotten that wrong.
The goal here is to be able to describe a function as mentioned in the article, that can accept any number of functions (either as varargs or a single list of functions), and ensure that the input of each provided function has the same type as the output of the function that precedes it.
data AlignedFunctionList a b where
Identity :: AlignedFunctionList x x
Pipe :: (x -> y) -> AlignedFunctionList y z -> AlignedFunctionList x z
pipe :: AlignedFunctionList a b -> (a -> b)
pipe Identity a = a
pipe (Pipe f g) a = pipe g (f a) (&) :: a -> (a -> b) -> bSo, `(a -> b) -> (b -> c) -> (c -> d) -> ... -> a -> z`.