TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Generate semi-dynamic UIs with Haskell

70 点作者 pka大约 5 年前

2 条评论

dmitriid大约 5 年前
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 未加载
ivanbakel大约 5 年前
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 未加载