3 ms·
Haskell can do this, although it's pretty unidiomatic: data AlignedFunctionList a b where Identity :: AlignedFunctionList x x Pipe :: (x
by consilient 4y ago
Haskell can do this, although it's pretty unidiomatic:
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)
- yakshaving_jgt 4y agoI must be missing something, but in Haskell this “typed pipe” (which is just reverse application) already exists in the base package as Data.Function.&. (&) :: a -> (a -> b) -> b
- siknad 4y ago> that can accept any number of functions So, `(a -> b) -> (b -> c) -> (c -> d) -> ... -> a -> z`.
- yakshaving_jgt 4y agoAh, right. In that case I suppose you'd want some kind of fold.