loading...
Cover image for 92nd :: decomposing Haskell

92nd :: decomposing Haskell

dooygoy profile image Domagoj Miskovic Updated on ・4 min read

A characteristic feature of functional programming is that if an expression possesses a well-defined value, then the order in which a computer may carry out the evaluation does not affect the outcome.

"But in what way does not affect the outcome?" and thinking thus begins, so let us compare an imperative and a functional view, compare as in these paradigms seem to be more than just two paradigms, being like two sides of the same coin they describe different properties of an outcome itself, outcome as an abstract fixed point, some abstract fixity, a term that just got stuck in my head, from reading the A Type Of Programming.

Brian Beckman has a great line in his talk the zen of stateless state:

The whole point of passing things around in function arguments is to avoid an implicit state, it's still state, it's just passed around explicitly in function arguments. The problem in distributed and concurrent programming is if you have an implicit state, some place where you're updating variables, and now if you have two processes updating the same variables, they don't know when a variable has such and such a value. If you're changing the meaning of sine 1.1, which answer are you gonna get back? Are you gonna get todays answer or tomorrows answer, you don't know, you gotta coordinate, so you have to have some other mechanism for coordinating... (understood).. and its implicit its hidden from the program. This stuff is all in the program text itself, so you just by looking at the program you can tell whats going on, states being threaded around through function arguments, woah, phew, we're safe, the coordination of updating and passing the state is explicit, everybody knows whats going on, its just, the downside of it is that every function gets its state argument and you can get rid of that by going to a monad, and it's a little slight of hand, it's actually very beautiful... (turns around) and general! Because it's just one kind of monad, there's a list monad, there's a maybe monad, there's a continuation monad, all these things have the same kind of compositional patterns, all about being able to compose these things that do these sophisticated operations, like passing state around.

I’d like to put the thing being observed into two domains of impure and pure patterns, impure because its properties are randomly described with hidden side effects shared between its descriptions, meaning some of these patterns contain isomorphic, self similar patterns dispersed within a subset of elements, some hidden equivalence within a larger set of some described state, and pure patterns described by pure functions, which are made out of pure expressions, expressions that define explicit state relations, a state described as a complete relation of all states. Pure patterns totally describe themselves while impure patterns live inside of partial function spaces, where certain elements are like locked constants impenetrable to the observers gaze, thus partially one can never so to say finish the job, finish the sequence in place because temporally we keep losing the memory of our shared state. Maybe I could say that pure expressions are in some way ordered, we could make a precise scale since each could be passed with their individual state, meaning everything is explicit, out there for us to witness and manipulate.

And yet who is manipulating what here? Why is the programmer constantly forced to provide the problem and implement the solution, almost like a madman thinking with its own self? With imperative paradigm one seems to follow along the patterns using loops, which are expressed as informal language hiding the actual abstraction, merely updating the counter, the state, like counting numbers one, two, three, until a random number comes next.

Alt Text

I am still thinking to myself, thinking with Haskell, and to be honest, which is quite sad, I am still not interacting with the Haskell compiler, with the glorious GHCI. Why? Can GHC teach me Haskell? Are there any educational functional spaces where I could interact with it like with OK, Google, or could I ask Siri to show me a pure function space? Paradoxically, the more I learn Haskell and category theory, the more I wish to just keep optimizing the learning experience by understanding structures and more, a wish for creating a program is born, a helper program, an independent entity whose orientation is Haskell space, that can interact with the user, ask questions and even visually represent function application calls. I wish to manipulate types and by the side of code see like Tron colored neon lights dynamically showing me in real time the progression of types, how they unfold, which directions they may go, what are the operations that could encapsulate larger structures…

How would such a program compose? It cannot be just a simple database, a lookup table, a dictionary of some sorts which would just pull out the abstraction that was asked in place, I mean where is the fun of it, where is the play in all that? Haskell show me something new within the properties I describe to you, and scale functionally meaning scale the complexity of relations so that I can follow you along.

Discussion

pic
Editor guide