Re:Once you go functional, you can never go back
by sriku on Wednesday May 20, 2015 @11:55PM
(#9580874)
You're partially right, but function composition features in the type world too. For example, when you say -
data Tree a = Leaf a | Branch (Tree a) (Tree a)
It looks like you're dealing purely with types, however you've declared two constructors "Leaf" and "Branch" which are, in essence, functions with the following signatures - Leaf :: a -> Tree a
Branch :: Tree a -> Tree a -> Tree a
Additionally, you have `Branch` being an operation that's closed on trees (i.e. maps trees to trees), which composes nicely.On top of that, type classes are mechanisms to talk about which functions can be called on which data, hence guiding which functions can be composed with which others.
The ML family, for example, lets you model a lot of things in type specification, and Haskell goes even further making types a good model even for behavior. And Lisp has a deep focus on metaprograming.