Thursday, March 13, 2014

Monadic Functional Reactive Programming

Reactive programming - programs that interact with the "outside world" - present a problem to the pure functional programmer: how to program in the traditional style in the absence of updateable state? But problems can also be opportunities, and in this case the opportunity is to rethink the problem from a different perspective. The result that ensues is "functional reactive programming", often abbreviated to FRP, originated by Conal Elliott and Paul Hudak.

The essence of FRP is to think declaratively, or in other words to think about how to make a mathematical model of the problem domain. The key insight is then to see that the functional world offers just the right set of abstractions to do this. A continuously varying quantity - such as the position of an object in an animation (or indeed in a robot world) - a given by a function from time to coordinates. Continuous quantities can trigger discrete events, for example when a position exceeds a certain value, and conversely events can trigger changes in continuous quantities - such as the rebound of a (simulated) billiard ball from a (simulated) cushion. So, FRP gives very general - and declarative - models of hybrid systems.

So far, so good. We have a very powerful model of a very general set of systems, but how is this to be implemented? We are in a functional language, so we can describe a naive implementation, but sadly that is desperately inefficient, and so the history of the last decade or so has been one of searching for sufficiently efficient implementations gained without losing too much of the original power and elegance of the framework. One approach is to make everything discrete, which is the approach of the Lustre language, but aiming to keep as close to true continuity as possible, at least as an abstraction, has proved to be more of a challenge. Elliott has provided a number of implementation ideas, as has Nilsson; the paper here provides a new approach in which a monadic interface is designed for FRP. 

Under the monadic approach, continuous behaviours are allowed to terminate (and also to begin) and so there is a natural sequencing operation between them. As well as giving a more familiar API to the programmer, the author claims that this allows a clean - i.e. declarative - yet efficient implementation of the system. While it is too early to give a definitive judgement on this - we should wait to see what the take-up is - it may be that finally FRP has come into its own with this work. If so, we can look forward to a whole set of new libraries for high-level reactive programming in interface design, graphics, web programming and more. Watch this space …

This review of Monadic Functional Reactive Programming, from the 2013 Haskell Symposium, was drafted for Computing Reviews, but too long for their liking. So, I have posted it here instead :-(

Tuesday, February 18, 2014

Why I lecture

Sometimes it's a real joy to give a lecture: the topic is right, and you have managed to get the slides to say what you want without clutter or confusion. This happened to me today, in giving my final lecture  for a while in our “Functional and Concurrent Programming” course at Kent. I wanted to pull together all that we'd covered about functional programming, and do this by treating a “meaty” example. I chose language processing: here's the lecture recording and here are the slides.

Why choose language processing? It’s central to a CS course: even if our graduates are unlikely to write a compiler, there’s a much higher chance of writing something that will manipulate XML, or a domain-specific language, or build scripts, or test code … the list goes on. It's also a place where the combination of immutable data, expressive structured types, a highly developed lists library, and an interactive development loop work really well together.

Thursday, January 30, 2014

Planning redux

I can't resist posting a link to my previous post on planning after receiving a 9 page document instructing us how to write departmental plans.

OK, 3 pages are templates, so that leaves only 6, to describe what should itself be a maximum of 6 pages, plus tables … of course, this should also take into account the university's institutional plan, 20 lavishly-illustrated pages.

Transition to grumpy old man complete, I think …

Monday, December 2, 2013

How to stand out digitally


I was asked by Adam Jolly to give some advice about the web and its value to small businesses for his forthcoming book The Growing Business Handbook. I'm very happy to acknowledge help from colleagues in the KITC, and particularly Vishal Soni and Jason Marshall 


The article


If you are searching for growth, look online. In the UK, the web economy now accounts for 8.5% of all activity, which is a higher figure than any of the world’s other main markets.

To give you a sense of scale of the change that is happening, consider online groceries. They already account for 4.5% to 5% of the market. If they continue growing at their current rate of 15% a year, their share will be 10% to 12% by 2020.

So how can you as a small enterprise start capturing this potential? Here are a series of relatively easy steps that you can take that might end up transforming your business without saddling yourself with too many extra costs.


Phase 1: web presence


First, change your mindset. It is no longer a matter of thinking whether you should be online, but about how you must build your presence.

At a minimum, whether you are florist in Canterbury, a curry house in Margate or anyone else, you have to create a basic web page. It is how your customers now find you. Many brands represent themselves through their “domain name” like google.com, or amazon.co.uk, so it’s worth finding which domain name you can purchase for yourself, such as floratheflorist.co.uk. This name will then be a key part of your overall brand, and you can then publicise it through local online directories, many of which are free.

At this web site, as well as saying who you are and where you are, you can start adding details that your customers will find useful, such as what you have on the menu or what bouquets you might recommend for different occasions.

Alongside your own activities, it will be worth placing yourself within a wider picture. As a florist, you might point customers towards your preferred maker of vases and carry a link to an online ordering service like Interflora.

Similarly, at the restaurant, you might plug yourself into a national infrastructure for making bookings. Any visitors are likely to go through one of these networks in planning their trip. Like most of us, they are likely to rely on recommendations from other customers on sites such as Trip Advisor. These reviews can be highly influential in how anyone unfamiliar with your area makes their spending choices.


Phase 2: social media


So far, you are still taking a relatively passive digital approach. On the web, you generally rely on customers to come to you. On social media, or Web2.0 as it’s sometimes called, you can connect them with more directly.

If you build your own page on Facebook, you can start sending out messages to those who choose to like you, highlighting any special offers you might be running.

On Twitter, you can create an account for yourself by finding a name that no-one else is using and put a @ in front of it, like @floratheflorist. Anyone who follows you will then receive your tweets. It is a powerful way of starting to build a relationship.

When you tweet, you can highlight any words or phrases, such as flowers for Easter, with a hash tag #flowersforeaster. Anyone who is searching for that hash tag will then find you.

You need to find followers, of course. People may give you all sorts of different advice, but probably the simplest way is to follow people: if you follow them they are more likely to follow you. Then, once anyone comments on you and you respond, all their followers will see what you have to say. Another way of attracting followers is to forward (or “retweet”) others’ tweets.

Advertising on the web has completely changed how advertising works. Instead of placing an ad in a newspaper, and hoping that some of the readers will respond, it’s now possible to target your advertisements. You can choose to advertise to people who search for particular words, and you only pay when someone has clicked on the link to read more. The cost will depend on the level of demand for any combination of words. ‘Cheap booze’ is likely to command a premium. ‘Curries in Margate’ or ‘flowers in Canterbury’ are likely to much more affordable.


Phase 3: e-commerce


Once you have worked through these options, you will have created your online presence. The next stage is to start making sales directly through e-commerce. Again, you can go a long way without incurring too many upfront costs, or too much technical effort.

You can create your own shop on e-Bay, who, as well as running auctions, let you sell direct through their ‘buy it now’ option. Or you can become a partner on Amazon and appear on its listings when customers search for your type of product. For services, like hotels and restaurants, sites like Trip Advisor are now moving beyond its origins in customer advice into linking directly to hotel booking sites like hotels.com. If you want to sell through your site, companies like PayPal will process payments for you, saving you the complications of managing credit cards.

Potentially, such activities will transform the nature of your business. Think about second-hand books. We used to travel the country, dropping into shops in the hope of finding a title. Now you can essentially see a whole country’s stock of second-hand books on a site like abebooks.com in an instant.

Equally, in your own business, you might start expanding into areas you never thought possible before. Our florist in Canterbury, for instance, could look at selling animated cards to send with bouquets.


Phase 4: brand dialogue


By inviting your users to start conducting a conversation with your brand, you are moving from a static presence online to a more dynamic two-way flow. But how do you keep yourself fresh and ready to engage? 

Right at the start, you want to make sure that you retain the option to manage your content. Many of the companies we see at the University of Kent tend to create a striking first site, which they struggle to adapt as the nature of their business changes and expands. One way of keeping your site up to date is to use a Content Management System (or CMS); your web site developer can advise you about this.

Later, as you move into social media, you have to be ready for the eccentric and unexpected comments that you might attract. So it is worth thinking in advance about the tone you might adopt. If a slip-up happens, rather than being defensive, it is generally better to be graceful. Your relationship with your customers and clients has changed: now you are in a conversation with them, and keeping track of what’s happening on your social media is something that you need to keep on top of. That way, you can keep building your audience.


You’ve seen how quickly things have changed in the last five years with the advent of twitter … one thing for sure is that there will be the same number of surprises in the next five years, so keeping up with what’s going on on the web is a real priority for all small businesses.


Social media policy 


  • Define: What type of company you want to be seen as - informal, formal etc. Remember your target audience.
  • Time: Online promotions and monitor the response
  • Monitor: What is the sentiment toward your business and topics related to you
  • Respond: To the key topics that are related to your business and to your target market

The Kent IT Consultancy


The Kent IT Consultancy is an IT consultancy based in the School of Computing at the University of Kent. Its mission is to support the community by solving business problems with technology, as well as providing its students consultants with the skills to make them more employable. Its motto is “the graduates of tomorrow supporting the businesses of today”.

Thursday, November 28, 2013

Transformed by You (updated)

I spent Saturday in Tunbridge Wells Town Hall with three of our first year students and a whole lot of other participants at the Transformed by You event. The idea of the event was to bring together people interested in building computer systems - often apps - that will have a positive effect on the community. Specifically they should do on of three things

  • encourage people to help each other out - e.g. by doing some gardening for someone;
  • encourage people to get healthier, by eating better, or exercising more;
  • encouraging artistic and cultural activity.


  

So, what was it like? Our students – Ed Wellbrook, Viorel Tudose and Panayiotis Christofides – had gone along with ideas for
  • a recipe app for students,
  • a "treasure hunt" app for local area events, and
  • an app to help encourage use of the gym.
During the day they worked on presentations of their ideas, in collaboration and comments from other attendees. This gave them useful feedback on their ideas, and helped to focus what they were aiming to do; they also gained experience of building quick prototypes (result: it's not as quick as you would hope … ).

I was also able to spend some time with one of the other projects, ThinkHealth from Gravesham NHS Trust, which was one of the winners of the day. Interesting there to see how an internal NHS project for promoting health among staff might well be rolled out to companies as part of their occupational health schemes.

Finally, we had the archetypical hacker lunch, coke and Pizza from Dominio's – a first for me: I didn't really take to the barbecue sauce instead of tomato on some of the bases :-S

Updated …

On the following Thursday, Noel visited Kent to watch the one minute videos made by our students. Here are our CO334 tutors – Keith, Dan and Minas – watching them too, complete with popcorn:



He also revealed winners among the students, who took all three prizes in the ideas section of the competition organised by public sector organisation Kent Connects.

Their ideas included two mobile phone apps to help motivate people to exercise. One - Exercise Escape, developed by computing students Ruhul Amin and Jacob Fox - involved a game which would encourage users to run from virtual enemies. The other - Motivated by Fiction, developed by computing student Matthew Aldridge - would encourage people to exercise by drip feeding them parts of a story each time they used the app when running or walking. Fault Finders was the third winner in the ideas categories; an app developed by computing student Christina O'Docherty to help businesses find ways they can help their local community.

Carol Patrick, Kent Connects' Head of ICT Partnerships, said: "We were really impressed by the quantity and quality of ideas sent in by people wanting to find ways to improve their local community and we're now looking forward to these ideas and prototypes becoming a reality."

Monday, November 18, 2013

These are a few of our favourite things …

I have the pleasure of convening the module on “Developing as a Researcher in Higher Education” that is part of Kent's qualification for new staff. In the first session participants each gave a one minute presentation – excellent timekeeping, incidentally – on their research. It's fantastic to hear all these diverse topics, and the enthusiasm of the people working on them. Here's a selection

  • how does stand-up comedy work?
  • how to make a performance of taste (of wine)?
  • how is performance affected by place 
  • architecture (practitioner)
  • how to capture what clients of software houses really want?
  • how to improve the efficiency of wireless networks … adaptively
  • what is the role of language in social work?
  • micro-meteorites (≦2mm) … not least, how on earth do you find them?
  • theoretical physics
  • Bayesian decisions in mathematics
  • theoretical syntax, and the disappearance of if/whether in Icelandic
  • a new theoretical / jurisprudential platform for critical legal studies
  • torture and the state, aboriginal art and constitutionalism
  • use of cool materials (in architecture)
  • what makes an action successful?
  • Lea Valley Drift: bringing the immediately available city back into prominence
  • Gender in International Cooperation
  • Is there a pool of talented people being lost [to HE]?
  • Sustainability Research in Business Practice and CSR
  • Modelling faking in high stakes self-assessments and biases in assessments of others
  • Napoleon, The Cardinal and the Prostitute
  • Sociology of the Professions - particular focus is on equality, diversity and inclusion
  • Political psychology, specifically: self-esteem and narcissism
  • the brain basis of remembering

The only disappointing thing is that we don't really have time to talk about them in the sessions for the course.

Sunday, November 17, 2013

REF Factory

Writing the REF submission for Computing at Kent is drawing to a close, agonisingly slowly, but there we are … Now is the time to capture any insights about how it might have been done, and how it could be done next time (I'm not volunteering!). I'll write this now, and then finish revising my first publication for REF 2020: final copy is due to be with the ACM in a couple of days' time.

Kent made the decision to hold a full-scale pilot in 2012, so that we had been through the process of writing all the narrative sections, the impact case studies, and – in the case of computing and a few others – the 100 words accompanying each output, about 120 for us. This had some strong points, and it was particularly good in giving us a deadline by which we had to have written a first draft of everything, so that the last year has been a process of refining those drafts.

On reflection, though, it has – at least for me – meant that we (or I) have conflated two quite different processes:

  • the process of marshalling the arguments, information and data, and 
  • the process of writing that within the constraints of the 100 word limit, or the various templates.

I did have long drafts – essentially compilations of data and info – prior to the pilot, but since then, we've been working on drafts in the form of the final submission. What I'd do if we were doing this again is to keep the separation between the two until much later in the process, and work on the raw information and data until a much later point. Doing that means that we're able to get an overall view of all that might be pertinent, rather than selecting, and then re-selecting, which is what we've done. For example, I had included data on staff study leave in a draft of REF 5 in May, but that was removed in June, only to be re-introduced in November. 

The same applies to the 100 words, I think; a subject I discussed with another REF coordinator recently. Aiming to get all the pertinent information collected for each potential paper (with a few prompts about different kinds of info), and to keep that up to date and reviewed, would allow the final 100 words to be generated close to the deadline, rather than evolving over two years in many cases.

I realise that this may week be a case of the other person's grass always being greener, and that we would most likely find problems with this approach, but this is what I would try were I to do it again. In the case of the pilot submission, if we had to write it in that format, we should see it as a throw-away draft, and keep on marshalling until we write a new final draft from scratch.

Finally, the more I think about this, the more I think that this is very like a problem we come across in writing successful research grant applications. The most useful feedback on an application is at the stage where the ideas begin to be articulated clearly. One way of expressing this is as a “one pager” that summarises the essence of the ideas, the work packages, the methodology and the impact, all on one side of A4. As a reviewer it's possible to engage with this, and say “yes, but it would be so much better if you were to push it in this direction” – it's almost impossible to do this once it has been set in concrete in a complete application. In a roundabout way, that explains why I called this post “REF Factory” – Kent's well-regarded grant application training is called “Grants Factory”, a name coined by Andrew Derrington.