Difference between revisions of "Real World Applications/Event Driven Applications"

From HaskellWiki
Jump to navigation Jump to search
Line 6: Line 6:
   
 
* A loan application has been accepted/rejected (commercial business).
 
* A loan application has been accepted/rejected (commercial business).
* A new rostering schedule is ready for distribution (airline system).
+
* A new rostering schedule is ready for distribution to crew (airline system).
 
* A simulated car has hits another simulated car (commercial racing game).
 
* A simulated car has hits another simulated car (commercial racing game).
 
* A HTML message has been received (web server).
 
* A HTML message has been received (web server).

Revision as of 11:52, 2 July 2014

Introduction

An event driven application is an application that reacts to external events.

Examples of events would be:

  • A loan application has been accepted/rejected (commercial business).
  • A new rostering schedule is ready for distribution to crew (airline system).
  • A simulated car has hits another simulated car (commercial racing game).
  • A HTML message has been received (web server).
  • A key has been pressed (text editor).

The examples demonstrate that events can be anything from high level business events ("A loan application accepted/rejected") to low level events ("User pressed key").

In the following, I will show one way to architecture a Haskell system so that it can scale from small "toy" applications (dealing with low level IO events) to large scale "Enterprise" applications (dealing with high level business events).

Please note that this is not the only way to attack the problem. So please contribute your (clearly superior of course) alternative way to do it here: [[1] Real World Applications]

Events in Haskell

In the following, I define an "Event" to be a value describing something that has happened in the past. And yes this should really be called an "Event Notification" but life is too short :-)

Here is a straightforward way to define Events in Haskell:

data Event =
    EventUserExit            -- User wants to exit
  | EventUserSave            -- User wants to save
  | EventUserSaveAs String
  | EventUserUndo            -- User wants to undo
  | EventUserRedo            -- User wants to redo
  deriving(Eq,Show)

Events can be high level or low level depending on how "deep" in the system you are operating. Within a UI sub-system the events are typically low level (key pressed, window closed). In a large scale distributed system the events are typically high level business events (EventCustomerCreated <details>).

Main

Growing the Application

  • Crash Recovery
  • Undo/Redo
  • Time
  • UI
  • Databases
  • Client/Server

Your Contribution Here

Please contribute additional/alternative ways to structure large scale Haskell applications here.

Questions and feedback

If you have any questions or suggestions, feel free to mail me.