I want to do something like this:
getValue :: Element -> String
getValue x = do
v <- get UI.value x
v
However, an error is thrown; the expected type of get UI.value x
is [String]
but the actual type is UI String
?
But if I change the type signature to getValue :: Element -> UI String
, my last v
gets the error of expected type UI String
while its actual type is String
.
I'm trying to implement something like this:
myfunction window = do
words <- getElementsByClassName window "word"
let strs = map getValue words
Since I can't say let strs = map (\x -> v <- get UI.value x) words
.
When I only have one element to deal with, I'm fine:
filename <- chooser # get UI.value
liftIO $ print filename
unless (null filename) $ do
prevRows <- getElementsByClassName w "row"
mapM_ delete prevRows
elems <- liftIO $ readJSON filename
mapM_ (element table # addRow) elems