Posts in category Haskell

Haskell Requires Perfection "When There is Nothing More To Take Away"

With Haskell perfection is not optional, but required. Otherwise one ends up deep into redundant abstract bullshit, unnecessary wrapping mess, which would be even worse than J2EE bullshit.

Another great example is brevity of speech of smart autistic people compared to verbal diarrhea of intelligence cosplaying imposers.

Dalai Lama speaks a few sentences at a time, but these are well though, have no redundancy no decoration and no long words to impress idiots.

This is precisely how Haskell code must be written - Just Right (the Buddha's principle) or the principle of Antoine de Saint-Exupéry: Perfection is achieved when there is nothing more to take away (which is implied in Buddha's Just Right).

The modern mantra for that is Data Dominates, which means that after finding the most appropriate (Just Right) data structures, the algorithms and the code (implementation) just follow.

For Haskell the mantra is Just Right Types, and everything else follows. It must be explicitly said - The most straightforward, down-to-earth types, such as Sequences, Trees, Tables (Traversable, Foldable, etc), NOT Free Monads and similar stuff.

Monads is just a convenient formal conceptual framework to enforce an abstraction barrier for a declarative (pure functional) language. No more, no less. Explicit order of evaluation is enforced by function call nesting, which is at the core of Monads (and Arrows) implementation.

Kleisli categories and stuff is just an abstract framework which provided an insight of how a barrier could be generalized.

Just this.

Oops, I monad again

This boils down to an ugly hack which is what a monad is.

The principle is that a function by definition is a mapping, which maps a set of values into another set of values. The crucial difference between a function and a procedures is that a function must, by definition, produce the same input for the same output. Always.

So, when a supposed function produces sometimes values and sometimes errors, everything is broken. It is not a function anymore. The ugly hack is to wrap different values into a compound structure of a certain type and reformulate the law of functions to the law of procedures - the same type of output for same values. This is what Maybe monad and Either monad are. Mere ADTs, mere wrappers. As long as input and output values are of the same type (as long as they conform to the same protocol/interface they are considered to be equivalent, but, of course, not equal) procedures which take such type as input and output values could be composed and form a pipelines (like any other procedures with consistent types).

There is nothing more than that. And, strictly speaking, it is not a pure functional programming anymore. Just procedural with static typing (hello, Haskell purists!).


Is there already a proposal to add that wonderful Type? syntax from Swift instead of ugly Maybes, at least as a standard syntac sugar?

It is so beautiful because it reflects a good tradition of naming predicates in Sheme and few other languages.

Destructuring is by pattern matching, as usual.

Every self-respected programmer..

..must do this at least once.)