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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Boilerplate busting in functional languages

27 点作者 ashton31412 个月前

5 条评论

Smaug12312 个月前
By the way, a classic:<p>&gt; A functional programmer is one who calls their variables `f` and `x`, and their design patterns &quot;zygohistomorphic prepromorphism&quot;.
评论 #40394051 未加载
munchler12 个月前
&gt; In languages that don’t have typeclasses, you need to take special steps to ensure that you dispatch to the proper variant of the monad.<p>You might want to take a look at F#, which has no typeclasses (yet) but does have excellent first-class support for monadic syntax via &quot;computation expressions&quot;.<p><a href="https:&#x2F;&#x2F;learn.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;fsharp&#x2F;language-reference&#x2F;computation-expressions" rel="nofollow">https:&#x2F;&#x2F;learn.microsoft.com&#x2F;en-us&#x2F;dotnet&#x2F;fsharp&#x2F;language-ref...</a>
评论 #40393379 未加载
chowells12 个月前
This severely underestimates the weirdness of the visitor pattern. It&#x27;s far more complicated than monads.
评论 #40392842 未加载
评论 #40394048 未加载
recursive12 个月前
&gt; This could work, but the fact that we are using global mutable state ...<p>What? Why would you consider using global state for this? I&#x27;d do it like this. Mutability without globals.<p><pre><code> export function transform(ast) { const queries = []; walk(ast.root, queries); return { ast, queries }; } function walk(node, queries) { &#x2F;&#x2F; recursively called on child nodes &#x2F;&#x2F; can mutate node, and append to queries } </code></pre> &gt; Surprise! This is exactly the writer monad! This whole post has been a monad tutorial in disguise!<p>Aha. That explains why it stopped making sense about 6 paragraphs ago.
评论 #40394585 未加载
评论 #40394190 未加载
hi-v-rocknroll12 个月前
Sounds like some Dunning-Kruger inability to grasp how to solve the problem working with the tools rather than imposing their ideas that don&#x27;t fit. If you need a &quot;global mutable variable&quot; in BEAM land, then you could just use a genserver or ETS. It depends if the solution needs to be a cluster-aware singleton or not.<p>In the case of business logic and Elixir, this is where you may need to write your own DSL to model domain logic (DDD). It makes it makes things more flexible and more maintainable than piling together mud and hoping it won&#x27;t fall over and that someone else in the future will be able to reason about it and maintain it.
评论 #40394547 未加载