I simply love it how every single Haskell framework I've seen that has "ease of development" and "it's easy" and similar immediately devolves from this (from Concur's docs [1]):
hello = do
button [onClick] [text "Say Hello"]
text "Hello Sailor!"
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.
Cool application of Haskell's purity-by-default. I'm slightly surprised this takes the approach of enumerating the whole input space to get all states, though - given that termination for big spaces isn't a priority, why not just explore all paths instead? Then you could return `Int` as much as you wanted, if the actual code only goes through finitely many different values.
The problem is that concur-static generates static JS code that encodes all possible UI state transitions - so if the state space is big or infinite, so will be the resulting generated JS.
I wanted to explore the viability of generating simple static UIs with some level of dynamism. concur-static is definitely not intended as a replacement for full-blown client side UI libraries/frameworks.
dmitriid|6 years ago
[1] https://github.com/ajnsit/concur-documentation/blob/master/R...
lalaithion|6 years ago
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.
chrissoundz|6 years ago
tome|6 years ago
ivanbakel|6 years ago
pka|6 years ago
Author here.
The problem is that concur-static generates static JS code that encodes all possible UI state transitions - so if the state space is big or infinite, so will be the resulting generated JS.
I wanted to explore the viability of generating simple static UIs with some level of dynamism. concur-static is definitely not intended as a replacement for full-blown client side UI libraries/frameworks.
unknown|6 years ago
[deleted]