threepenny-gui
joeyh at
This is the complete source code for a client-server web application that estimates the strength of a password the user enters, updating the estimate after every keystroke.
Note the total lack of html, javascript, routes, callbacks, or any of the usual web cruft. It's using the threepenny-gui haskell library and a little bit of FRP. Pretty awesome library, although the GUIs it renders only work when javascript is enabled.
import qualified Graphics.UI.Threepenny as UI
import Graphics.UI.Threepenny.Core
import Text.Password.Strength (estimate)
main = startGUI defaultConfig $ \window -> do
prompt <- UI.input
estimatedisplay <- UI.string ""
getBody window #+ [ element prompt, element estimatedisplay ]
promptIn <- stepper "" $ UI.valueChange prompt
let showEstimate = show . (`estimate` []) <$> promptIn
element estimatedisplay # sink value showEstimate
return ()
der.hans, Charles Stanhope, Scott Sweeny likes this.
der.hans shared this.