3 ms·
The second example can be rewritten as such: inputWidget = let changeAction = do v <- onChange return (Changed (unsafeTargetVal
by lalaithion 7y ago
The second example can be rewritten as such:
inputWidget = let
changeAction = do
v <- onChange
return (Changed (unsafeTargetValue v))
focusAction = do
_ <- onFocus
return Focused
in input [changeAction, focusAction]
and likewise for the third:
inputWidget st = let
focusAction = do
_ <- onFocus
return (st {focusCount = st.focusCount+1})
changeAction = do
v <- onChange
return (st {s = unsafeTargetValue v})
in input [focusAction, changeAction]
(I didn't compile this, so hopefully there's no major mistakes here)
Believe it or not, many Haskell programmers prefer brevity when it comes to programs like this. They're honestly not that unreadable once you learn the meaning of a few infix operators.
- dmitriid 7y agoI prefer the approach described here: http://www.haskellforall.com/2015/09/how-to-make-your-haskell-code-more.html http://www.haskellforall.com/2015/09/how-to-make-your-haskel...
- deleted 7y ago[deleted]