If you have ever written code in most modern programming languages and even languages that are not functional in nature there is a very high probability that you have used some form of monadic structure. A monad is a structure that represents computations defined as sequences of steps: a type with a monad structure defines what it means to chain operations, or nest functions of that type together. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad. As such, monads have been described as “programmable semicolons”.
Monads allow you to do things like method chaining, and flattening null and exception checks in highly nested code blocks.
1. Left identity
Identity.Compose(f) = f
2. Right identity
f.Compose(Identity) = f
f.Compose(g.Compose(h)) = (f.Compose(g)).Compose(h)
Example: Very basic Monad to factor out division by zero check in BMI calculation.
Monads are awesome, and I still have a lot to learn about them, however I can already see them everywhere in C#: IEnumerable, JQuery: Ajax Requests and lots more.
Until next time keep learning 🙂
Hi there, if you have been interested in Haskell and are not sure of what the IMHO best IDE for Haskell development is then you have come to the right place. For some time now I have doodled around with Haskell because of Microsoft F# which I want to learn at some later stage. F# is a functional language with capacity for the imperative and OOP style of programming, which most people are accustomed to. However, I decided to learn Haskell for the simple reason that it only does functional style programming, and would give a better foundation to functional programming than its F# counterpart.
So, to get started I went to Haskell.org and downloaded the latest version of Haskell for Windows. Once installed it provided a command line interface for working with Haskell in an interpretive way. It is possible to use this interface along with your favourite text editor to create programs; however, a dedicated IDE would be better. At this point my search for the best Haskell IDE begun. My first choice was Eclipse with a Haskell Add-In, the most vexing problem with this set-up is that auto-complete templates have to be created for Haskell and there is no support for intelli-sense with Haskell.
My search went on to Lecksah and concluded with Leksah, this IDE provided debugging, testing, and source control options for my Haskell programs. It also had auto-complete and intelli-sense out of the box; being a noob to Haskell means I will constantly need help with keywords and library references which are provided by the Leksah interface.
That said lets move on to the good stuff :-).This will be the beginning of a series of articles documenting my progression into this weird and wonderful world of functional programming, stay tuned for more.