[Haskell] Call for GUI examples - Functional Reactive Programming

Heinrich Apfelmus apfelmus at quantentunnel.de
Sat Jul 9 09:56:21 CEST 2011


David Barbour wrote:
> Heinrich Apfelmus wrote:
> 
>> Can GUI programming be liberated from the IO monad?
> 
> I believe it can be. But is FRP the right way to achieve this? Most of the
> GUI problems I've ever encountered involve open systems: configuration
> files, plugins, command and control, database crud, networking. Most of the
> FRP GUI examples I've encountered involve closed systems: calculators,
> tangible values, single-player games.
> 
> I am often left with the feeling that we're bridging the wrong gaps with
> FRP. Consequently, I've been developing a paradigm that adapts what I
> consider the best features of FRP for composition of open systems [1].
> 
> Anyhow, I'm guessing your query is because you'd like some sample problems
> upon which to whet your FRP model. Rather than a bunch of toy UI elements, I
> would suggest choosing examples with open elements, such as:
> * a personal wiki (cf. TiddlyWiki) with a file or SQLite database for
> persistence
> * a database browser/editor that reads the schema from the database and
> adapts the display appropriately
> * a Dr. Mario clone with support for online 2-player mode
> * an RSS display widget, configured with a bookmark file
> * a stock-ticker or weather-report widget with a simple configuration file
> * maps and KML
> 
> [..]
>
> I'm sure you can think of something more interesting to yourself, of course.
> The world needs proofs that open, dynamically configured systems are handled
> effectively in FRP. Or, if you struggle and the resulting code is inelegant
> without compromising the purity of FRP, well, that's useful information,
> too.

Nice examples. The real-time data display (stock ticker, weather) has 
been mentioned a lot, I will probably try that one.

I don't see any difficulties with open systems, though. Sure, you need 
some driver code to communicate, but it's all Events and Behaviors from 
then on. The function

     fromPoll :: IO a -> NetworkDescription (Behavior a)

is particularly nice, it allows you to interpret any data source as a 
time-varying value. For instance, here the completely random function 
that returns a random value at each point in time:

    brandom <- fromPoll (randomRIO (0,1) :: IO Double)


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




More information about the Haskell mailing list