Personal tools

PropLang

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
Line 35: Line 35:
 
There are bindings which relate variables.
 
There are bindings which relate variables.
   
<haskell>
 
 
-- the window text is the variable
 
-- the window text is the variable
 
window!text =<= variable
 
window!text =<= variable
Line 42: Line 41:
 
-- combine the two texts to create the window text
 
-- combine the two texts to create the window text
 
window!text =< with2 variable1 variable2 (++)
 
window!text =< with2 variable1 variable2 (++)
</haskell>
 
   
 
If any of the values on the RHS of a binding change, then the LHS is updated.
 
If any of the values on the RHS of a binding change, then the LHS is updated.

Revision as of 08:38, 24 July 2006

A design for a GUI library which is more like Haskell and less like C. To be written over Gtk2Hs.

Link: http://www.cse.unsw.edu.au/~chak/haskell/ports/

1 Thoughts by

Neil Mitchell, Duncan Coutts


For a darcs repo see: http://www.cs.york.ac.uk/fp/darcs/proplang/

In particular check out Sample.hs, I am particularly proud of the word count:

sb!text =< with1 (txt!text) (\x ->
    "Word count: " ++ show (length $ words x))

2 Overview

There are events, you can register to be notified when an event fires by doing

event += handler

There are variables, which have events which fire, and a value which you can set and get.

variable <- newVar "value"
variable += handler
variable -< "value"
x <- getVal variable

There are objects, objects have properties. A property is just a variable.

window!text += handler
window!text -< "Titlebar text"

There are bindings which relate variables.

-- the window text is the variable
window!text =<= variable
-- the window text is the variable, but upppercase
window!text =< with1 variable (map toUpper)
-- combine the two texts to create the window text
window!text =< with2 variable1 variable2 (++)

If any of the values on the RHS of a binding change, then the LHS is updated.