I'm really new to using the threepenny gui and I want to do something like this:
on UI.click button $ const $ do
element reverseArea # set UI.text (reverse (get value area))
So when i click a certain button on the page i get the text from a textarea, reverse it and display it in a different text area. However when i try run this, I get the error :
Couldn't match expected type ‘[Char]’ with actual type ‘UI String’
So I wanted to know how could I remove the UI monad so I can manipulate the text
I am not familiar with threepenny-ui, but I guess you need something like this:
The rough idea is: when you have a value of type
UI Stringyou can usex <- valueinside adoto get the string (withoutUI) and bind it to variablex. You can only do this if the rest of thedoclock at the end returns value of a typeUI Tfor some typeT.So, use
<-as needed to get the pure values.By the way, this is not specific to
UI: every monad follows this principle. You will find plenty of monad tutorials around the net.