Skip to content

bradrn/dunai-gi-gtk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dunai-gi-gtk

This is an illustration of how to integrate a GUI library (in this case gi-gtk) into dunai, using bearriver for arrowised FRP. Though still at a prototype stage it already provides a very convenient way to write programs, e.g. the following simple counter:

main :: IO ()
main = runGUI $ proc () -> do
    -- set up buttons
    (up, upBtn)     <- button "Up"   -< ()
    (down, downBtn) <- button "Down" -< ()

    -- compute value and display it
    value <- accumBy (flip ($)) (0::Int) -< lMerge ((+1) <$ up) (subtract 1 <$ down)
    valueDisplay <- entry -< T.pack . show <$> value

    -- layout widgets in boxes
    btnBox <- box Gtk.OrientationVertical -< updated $ sequenceA
        [ (,True,True,0) . Some <$> upBtn
        , (,True,True,0) . Some <$> downBtn
        ]
    windowBox <- box Gtk.OrientationHorizontal -< updated $ sequenceA
        [ (,False,False,0) . Some <$> entryWidget valueDisplay
        , (,True ,True ,0) . Some <$> btnBox
        ]
    arr updated -< windowBox

About

Integration of gi-gtk into Dunai FRP library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published