This post is not about functional programming but about plain old imperative languages (C, Java, Python ... replace the dots with your favorite imperative language). I will try to show that you are forced to invent monads if you want to define the meaning of imperative languages ! I have not yet seen this approach to monads in the blogs and tutorials available on the web so I thought it could be a good idea to say a few words about it.

 

I am doing some additional experiments with Haskell and web development. In this post, I am looking at the problem of composability for web pages.

I have tested different methods for building a web page and what I don't like is the lack of composability. When I look at most web pages, I see several components with their own state and control flow. But, when I build a web page from those components, the composability on the server side (for the request handlers) is less obvious.

 

If you read my previous post, you'll be interested by this one. Indeed, I have discovered that the idea introduced in the previous post is working but not practical at all since it does not work with type synonym definitions. But, without synonyms, you can't really write the kind of types required to do http content-type comparison at the type level. By luck, some additional type hacking is solving the problem. Moreover, I think it can be useful to show in a very informal way a few applications of computations at type level. It is not so hard (but not totally trivial. I had to make several experiments to get it right).

 

In my last post, I was writing about the use of coproduct of free monads to do content-type dispatching in a web monad. It was working but it was not the right approach. I changed everything and introduced a lattice of lists at the type level to track hierarchical dependencies between formats and do content-type dispatching thanks to type information. I also added a few other features to my Web Monad.

 

From time to time, I continue my experiments with Haskell and web development and try to build my own framework. I will never release anything because I am just exploring a few ideas.

Recently, I experimented with a common problem : when a client is getting an URL, it is communicating the formats it wants with some preference values. The server should return the best format according to what is requested by the client and what is supported by the server.