TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Generate semi-dynamic UIs with Haskell

70 pointsby pkaabout 5 years ago

2 comments

dmitriidabout 5 years ago
I simply love it how every single Haskell framework I&#x27;ve seen that has &quot;ease of development&quot; and &quot;it&#x27;s easy&quot; and similar immediately devolves from this (from Concur&#x27;s docs [1]):<p><pre><code> hello = do button [onClick] [text &quot;Say Hello&quot;] text &quot;Hello Sailor!&quot; </code></pre> into this:<p><pre><code> inputWidget = input [(Changed &lt;&lt;&lt; unsafeTargetValue) &lt;$&gt; onChange, Focused &lt;$ onFocus] </code></pre> or this:<p><pre><code> inputWidget st = input [st {focusCount = st.focusCount+1} &lt;$ onFocus , ((\s -&gt; st {currentText = s}) &lt;&lt;&lt; unsafeTargetValue) &lt;$&gt; onChange] </code></pre> for even the slightest modifications (which are not even complex in this case)<p><pre><code> These instances, allow a natural handling of return values using &lt;$&gt;, &lt;*&gt;, &lt;$, monadic do-notation, etc </code></pre> Right...<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;ajnsit&#x2F;concur-documentation&#x2F;blob&#x2F;master&#x2F;README.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ajnsit&#x2F;concur-documentation&#x2F;blob&#x2F;master&#x2F;R...</a>
评论 #22728722 未加载
评论 #22728418 未加载
评论 #22729431 未加载
ivanbakelabout 5 years ago
Cool application of Haskell&#x27;s purity-by-default. I&#x27;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&#x27;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.
评论 #22728347 未加载