setup :: Window -> UI ()
setup w = do
    return w # set UI.title "ELF Parser"
    UI.addStyleSheet w "style.css"
    input <- liftIO $ B.readFile "linker"
    case ELF.parse ELF.parseFile input of
        Right value -> do
            let Just (ELF.BinarySection sectionOffset stream) = ELF.sectionFromName ".text" value
            setupJavascript w
            div <- UI.div
            body <- getBody w
            element body #+ [element div]
            canvas <- UI.div #. "asm-block"
            {--on (domEvent "resize") body $ \_ -> do 
                width <- body # get elementWidth
                height <- body # get elementHeight
                element div # set text (printf "(%d,%d)" width height)--}
            element body #+ ((UI.h1 # set UI.text "ELF Header") : (displayElfHeader (ELF.header value) ++ [element canvas]) {-++ [displayElfCanvas value] -})
            runReaderT (displayElfTextSection (parseArmBlock 0 stream)) (canvas,value)
            return ()
        Left d -> do
            getBody w #+ [UI.h1 # set UI.text ("Error while parsing: " ++ d)]
            return ()
setup :: Window -> UI ()
setup w = do
    return w # set UI.title "ELF Parser"
    UI.addStyleSheet w "style.css"
    input <- liftIO $ B.readFile "linker"
    case ELF.parse ELF.parseFile input of
        Right value -> do
            let Just (ELF.BinarySection sectionOffset stream) = ELF.sectionFromName ".text" value
            setupJavascript w
            div <- UI.div
            body <- getBody w
            element body #+ [element div]
            canvas <- UI.div #. "asm-block"
            {--on (domEvent "resize") body $ \_ -> do 
                width <- body # get elementWidth
                height <- body # get elementHeight
                element div # set text (printf "(%d,%d)" width height)--}
            element body #+ ((UI.h1 # set UI.text "ELF Header") : (displayElfHeader (ELF.header value) ++ [element canvas]) {-++ [displayElfCanvas value] -})
            runReaderT (displayElfTextSection (parseArmBlock 0 stream)) (canvas,value)
            return ()
        Left d -> do
            getBody w #+ [UI.h1 # set UI.text ("Error while parsing: " ++ d)]
            return ()
setup w = do
    return w # set UI.title "ELF Parser"
    UI.addStyleSheet w "style.css"
    input <- liftIO $ B.readFile "linker"
    case ELF.parse ELF.parseFile input of
        Right value -> do
            let Just (ELF.BinarySection sectionOffset stream) = ELF.sectionFromName ".text" value
            setupJavascript w
            div <- UI.div
            body <- getBody w
            element body #+ [element div]
            canvas <- UI.div #. "asm-block"
            {--on (domEvent "resize") body $ \_ -> do 
                width <- body # get elementWidth
                height <- body # get elementHeight
                element div # set text (printf "(%d,%d)" width height)--}
            element body #+ ((UI.h1 # set UI.text "ELF Header") : (displayElfHeader (ELF.header value) ++ [element canvas]) {-++ [displayElfCanvas value] -})
            runReaderT (displayElfTextSection (parseArmBlock 0 stream)) (canvas,value)
            return ()
        Left d -> do
            getBody w #+ [UI.h1 # set UI.text ("Error while parsing: " ++ d)]
            return ()