Tom Schrijvers, Peter Stuckey and Philip Wadler Abstract: A constraint programming system combines two essential components: a constraint solver and a search engine. The constraint solver reasons about satisfiability of conjunctions of constraints, and the search engine controls the search for solutions by iteratively exploring a disjunctive search tree defined by the constraint program. In this paper we give a monadic definition of constraint programming where the solver is defined as a monad threaded through the monadic search tree. We are then able to define search and search strategies as first class objects that can themselves be built or extended by composable search transformers. Search transformers give a powerful and unifying approach to viewing search in constraint programming, and the resulting constraint programming system is first class and extremely flexible. Let's briefly look at the n queens example from the paper. First, there is the nqueens model:
I only managed to partially apply the Haskell talk — Yoda speaks Haskell, which was a shame in many ways because the small bit at the end was the most interesting. In the talk I said I wasn't trying to teach these aspects of functional programming, just to show what exists and how they can be used. Basically enough to try to interest people in functional programming by letting them see what they can do and hopefully giving enough to prompt them to go and experiment and learn more about it. In continuing from the end of the talk we had some working code that turned this: [ "fear", "anger", "hate", "suffering" ] Into this: "Fear leads to anger. Anger leads to hate. Hate leads to suffering." The code we had was this¹
Suppose someone stole all the monads but one, which monad would you want it to be? If you're a Haskell programmer you wouldn't be too bothered, you could just roll your own monads using nothing more than functions. But suppose someone stole do-notation leaving you with a version that only supported one type of monad. Which one would you choose? Rolling your own Haskell syntax is hard so you really want to choose wisely. Is there a universal monad that encompasses the functionality of all other monads? About a year ago I must have skimmed this post because the line "the continuation monad is in some sense the mother of all monads" became stuck in my head. So maybe Cont is the monad we should choose. This post is my investigation of why exactly it's the best choice. Along the way I'll also try to give some insight into how you can make practical use the continuation monad.
10 Great Implementations of Facebook Connect January 12, 2009 - 9:39 am PDT - by Ben Parr Facebook Connect mania has swept the Internet! Why create an account on a random website when you can click a single button to join? That is the power of Facebook Connect, which allows websites, software, and even mobile devices to integrate with Facebook and send information both ways. The last few months have been very busy ones for developers as they furiously integrated their websites with Facebook Connect. But a few implementations have stood out against the rest. Some are on this list because of the seamlessness of their integration, while others for their usefulness.
One of those things I have to do fairly often in multithreaded programming is send off a whole bunch of threads to do their thing while I do something else on the main thread until they’re done. For example, imagine you’re downloading a bunch of images from the web, you don’t want to call httpGet one image right after another, because network resources are slow and processing them takes up almost no CPU time. But on the other hand, forkIO doesn’t return anything, so a thread thunk will have to put its contents somewhere you can access them later. Thus, my short, simple solution, far too small to bother putting up on Hackage: module Control.Concurrent.Future where import Control.Concurrent future :: IO a -> IO (MVar a) future thunk = do ref <- newEmptyMVar forkIO $ thunk >>= putMVar ref return ref forceAll :: [MVar a] -> IO [a] forceAll = mapM takeMVar