有没有更原创、更实用的 Haskell Web 框架?

发布于 2024-10-10 07:57:17 字数 190 浏览 0 评论 0原文

我研究了 Snap 和 Yesod 等 Haskell Web 框架。大多数似乎都实现了类似 MVC 的方法,这让我想起了 Ruby on Rails 等 Web 框架。是的,MVC 可以通过 FP 实现,但恕我直言,它并没有显示出 FP 方法的巨大优势。由于 HTTP 是一种无状态协议,我希望可能有一个 Haskell 框架采用更原始、更纯粹的函数式方法。有吗?

I looked at Haskell web frameworks like Snap and Yesod. Most seem to implement an MVC-ish approach reminding me of web frameworks like Ruby on Rails. Yes, MVC can be achieved with FP, but IMHO it doesn't show the great advantages of an FP approach. As HTTP is a stateless protocol, I would have hoped that there might be an Haskell framework that takes a more original, more pure functional approach. Are there any?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黒涩兲箜 2024-10-17 07:57:17

我不确定您希望框架使用 FP 中的哪些功能,但我认为 Yesod 使用某些功能会带来很大好处。 (Happstack 也这样做,但我只是不太熟悉它。)

  • 类型安全 URL 消除了一整类由打字错误生成的错误,并自动处理输入验证。

  • 正确的输入实际上可以消除 XSS 攻击。

  • 根据您处理的数据范围,使用 STM 或 MVar 来满足您的存储需求可以轻松避免多线程应用程序中的竞争条件和死锁。

我确信还有很多我没有想到的事情,但我希望这能说明问题。但也许您正在寻找类似基于延续的框架。我个人认为它们是一个坏主意(我是 REST 的信徒),但我认为它可能看起来更“实用”。

I'm not sure which features in FP you would like a framework to utilize, but I think Yesod uses some features to great benefit. (Happstack does as well, but I'm just not as familiar with it.)

  • Type-safe URLs eliminate an entire class of typo-generated bugs, plus automatically deal with input validation.

  • Proper typing practically eliminates XSS attacks.

  • Depending on the scope of data you're dealing with, using either STM or MVars for your storage needs make it easy to avoid race conditions and deadlocks in multi-threaded applications.

I'm sure there's a lot more that I'm not thinking of, but I hope that makes the point. But perhaps what you're looking for is something like a continuation-based framework. I personally think they're a bad idea (I'm a believer in REST), but I suppose it might seem more "functional."

独行侠 2024-10-17 07:57:17

这取决于您想要实现的目标。如果无状态你实际上指的是无状态,我使用模板框架 Hakyll 来生成静态页面。它有一个有趣的结构来处理依赖关系和文件更新。

It depends what you're trying to achieve. If by stateless you actually mean stateless, I use the templating framework Hakyll to generate static pages. It has an interesting structure to deal with dependencies and file updates.

初心未许 2024-10-17 07:57:17

我认为 WardB 询问的不是花哨的类型,而是 FP 的指示性/无状态语义,与 IO 和 STM 等事物的命令式/非指示性(通常是不确定性的)语义相反。
正是这个外延方面支持精确和精确。易于处理的推理。
术语“函数式”也被扩展为包含命令式/非指示式编程,这通常会导致混乱。
Peter Landin 建议 替换“功能性” ”用“外延”来帮助消除这种混乱。

我不知道有任何指示性(非命令性)Haskell Web 框架。
要实现这一目标,可能需要打破一些长期存在的强制性心理习惯。
这就是说:有趣的工作!

I think WardB was asking not about fancy types, but rather about the denotative/stateless semantics of FP, in contrast to imperative/nondenotative (and often nondeterministic) semantics of things like IO and STM.
It's this denotative aspect that supports precise & tractable reasoning.
The term "functional" has been stretched to embrace imperative/nondenotative programming as well, which often leads to confusion.
Peter Landin recommended replacing "functional" with "denotative" to help clear up exactly this sort of confusion.

I don't know of any denotative (nonimperative) Haskell web frameworks.
Getting there would probably require breaking some long-standing imperative mental habits.
Which is to say: interesting work!

鼻尖触碰 2024-10-17 07:57:17

我一直在寻找相同的东西,但还没有真正找到。具体来说,我正在寻找一种延续方法,使传统的 HTTP 会话变得不必要。这类框架在Scheme中非常流行。我发现的最接近的是 Chris Eidhof 对 Arc Challenge 的回答:-

https://gist.github.com/260052< /a>

这是一个粗略的原型,可能还需要很多人月才能成为可用于严肃工作的东西。如果我的 Haskell 技能更好,我可能会尝试开发它。

我也相信 WASH 也采取了这种方法,但似乎已经死了。我将希望寄托在 mysnapsession 上,因为我相信这也在寻找基于延续的会话工具,这将是令人兴奋的,因为 Snap 其余部分的质量及其背后的动力给我留下了深刻的印象。

I was looking for the same but haven't really found it. Specifically I was looking for a continuations approach that renders traditional HTTP sessions unnecessary. These sorts of frameworks are quite popular in Scheme. The closest that I found was Chris Eidhof's answer to the Arc Challenge :-

https://gist.github.com/260052

It's a sketchy prototype and probably many man-months away from being something that you could use for serious work. If my Haskell skills were better, I might be tempted to try and develop it.

I also believe that WASH also took this approach but that seems to have died. I'm pinning my hopes on mysnapsession as I believe that is also looking at a continuations based session facility which would be exciting because I have been very impressed with the quality of the rest of Snap and the momentum behind it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文