threepenny-gui

Mixing Threepenny-Gui and StateT

无人久伴 提交于 2020-01-13 19:29:31
问题 I have a question on the interaction of Threepenny-Gui with StateT. Consider this toy program that, every time the button is clicked, adds a "Hi" item in the list: import Control.Monad import Control.Monad.State import qualified Graphics.UI.Threepenny as UI import Graphics.UI.Threepenny.Core hiding (get) main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = void $ do return w # set title "Ciao" buttonAndList <- mkButtonAndList getBody w #+ map element

Haskell do clause with multiple monad types

半城伤御伤魂 提交于 2019-12-21 09:26:10
问题 I'm using a graphic library in Haskell called Threepenny-GUI. In this library the main function returns a UI monad object. This causes me much headache as when I attempt to unpack IO values into local variables I receive errors complaining of different monad types. Here's an example of my problem. This is a slightly modified version of the standard main function, as given by Threepenny-GUI's code example: main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = do

using threepenny-gui/reactive in client/server programming

倖福魔咒の 提交于 2019-12-13 12:22:23
问题 I am trying to figure out how to use Haskell threepenny-gui with its reactive functionality to write a program that lets the user select an item from a listBox send the selection to an external server get back a list of results from the server populate the listBox with the results repeat It seems I will need to use Handler , newEvent and register to do the above. If someone could point me to some existing code that does something like the above that would be great. The closest I have found is

Haskell UI do clause, how to print?

允我心安 提交于 2019-12-11 03:48:38
问题 This is a follow up question to this. I'm using a graphic library in Haskell called Threepenny-GUI. In this library the main function returns a UI monad object. I'm trying to execute a simple print command with no success. What is a right work around to enable printing for debugging purposes. Code: main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = do print "debug message 1 " Error: Couldn't match type ‘IO’ with ‘UI’ Expected type: UI () Actual type: IO () In

Trying to render fields in threepenny-gui with special behaviour

北战南征 提交于 2019-12-11 03:19:07
问题 What I want to do is set up fields which show detail when they're in focus, but summary when they're not. eg. a). when it loses focus (gets blur?), I save the value in a (State?) Map and then change the value to a function of the old value (ie. the summary value) b). when it gets focus - I replace the summary value with the old value that I saved in the Map I cant' figure out how to do this, but I think I probably need a state monad and the UI monad. My try is: renderField :: Map->Int->UI

Dynamic Elements based on Behaviour in threepenny-gui

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:55:56
问题 To put it simple, I am looking for a way to display a Behaviour (UI Element) . My actual use-case is displaying a table, which can be filtered. So I have a function tableElement :: String -> UI Element (the String parameter being the filter condition) and an input field filterElement :: Element , which represents the filter. The most natural way for me to combine these would be something like this: bFilter <- stepper "" (valueChange filterElement) displaySomehow (fmap tableElement bFilter)

using threepenny-gui/reactive in client/server programming

无人久伴 提交于 2019-12-04 18:14:32
I am trying to figure out how to use Haskell threepenny-gui with its reactive functionality to write a program that lets the user select an item from a listBox send the selection to an external server get back a list of results from the server populate the listBox with the results repeat It seems I will need to use Handler , newEvent and register to do the above. If someone could point me to some existing code that does something like the above that would be great. The closest I have found is GameThing.hs in the threepenny-gui samples directory (but it doesn't use register ). UPDATE: I am

Haskell do clause with multiple monad types

一个人想着一个人 提交于 2019-12-04 03:20:37
I'm using a graphic library in Haskell called Threepenny-GUI . In this library the main function returns a UI monad object. This causes me much headache as when I attempt to unpack IO values into local variables I receive errors complaining of different monad types. Here's an example of my problem. This is a slightly modified version of the standard main function, as given by Threepenny-GUI's code example: main :: IO () main = startGUI defaultConfig setup setup :: Window -> UI () setup w = do labelsAndValues <- shuffle [1..10] shuffle :: [Int] -> IO [Int] shuffle [] = return [] shuffle xs = do