Haskell - Again!
Six years later, it simply clicked. Hence, this post as a way to celebrate!
What is an application in Haskell
A Haskell application always has the return signature of
IO (). That is, a monad of the
unit output. It does not mean the output is nothing but rather one same thing: the unit
(). Meaning, the application shall terminate.
IO () <-> () -- Kleisli Category
Certain Haskell applications can be a transformation of environment into the
IO () category or a state transition into the
IO () category. Either way, respectively we should use:
runReaderT r m a runStateT s m a
m a is
The main business or objective of
main :: IO () is to convert all code paths to
ReaderT or other Monad transformers should function likewise with respective
runMonadT. For example:
main :: IO () main = runReaderT reader "tom.csv"
One thing to note is Haskell’s polymorphism. Where is
runReaderT defined? It is defined as
runReaderT :: r -> ma and due to polymorphism Haskell compiler knows
m == IO and
a == ().
What’s up with Category Theory?
Six years ago, I should have learned…
One must accept that Haskell is a brainchild of a group of mathematicians, the expression of their programming worldview. Therefore, to understand their line of reasoning, one must walk their path from the beginning.
The [in]famous quote
A monad is just a monoid in the category of endofunctors, what's the problem?
makes sense to me immediately after I took about 2 weeks to finish of the first series on Category Theory by Dr.Bartosz Milewski [https://youtube.com/playlist?list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_]. Take your time! Clear your mind of any precepts you have had regarding programming. Sip some coffee.
To appreciate Haskell, one must have a minimal knowledge of Category Theory. To learn Haskell is a practical way to maintain your interest in learning Category Theory.