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.

Okapi – A micro web framework for Haskell

83 pointsby njrc9over 2 years ago

7 comments

rstarastover 2 years ago
The way this does routing leads to quite hard to read code, compare <a href="https:&#x2F;&#x2F;www.okapi.wiki&#x2F;docs&#x2F;todo-app" rel="nofollow">https:&#x2F;&#x2F;www.okapi.wiki&#x2F;docs&#x2F;todo-app</a>:<p><pre><code> todoAPI conn = getTodo conn &lt;|&gt; getAllTodos conn </code></pre> with<p><pre><code> getTodo conn = do methodGET pathParam @Text `is` &quot;todos&quot; todoID &lt;- pathParam @Int ... </code></pre> so you need to keep in mind both the order of the alternatives in todoAPI as well as the bodies of the individual handlers. That gets unwieldy very quickly.<p>It also seems likely to lead to the same problems with error handling that you tend to get with combinator parsers, where you usually only get details about the last failing branch, while the interesting failure might have been an earlier one.<p>Quiz question (I don&#x27;t know the answer): What happens to a request for &#x2F;todos&#x2F;foo?
mark_l_watsonover 2 years ago
Looks really nice but I haven’t tried it yet. I wrote a small book on my take on Haskell programming using a small subset of the language (read for free on my web site <a href="https:&#x2F;&#x2F;markwatson.com" rel="nofollow">https:&#x2F;&#x2F;markwatson.com</a>). When I update my book I might add an Okapi example. I have played around with Spock for simple web apps and that is nice enough, but I am really impressed by the care in putting together the Okapi documentation web site. Great material, nicely presented.
njrc9over 2 years ago
The author of this framework is also doing very interesting work on building Haskell server pages [1], taking inspiration from redbean&#x27;s Lua server pages[2].<p>[1] <a href="https:&#x2F;&#x2F;monadic.systems&#x2F;post7" rel="nofollow">https:&#x2F;&#x2F;monadic.systems&#x2F;post7</a> [2] <a href="https:&#x2F;&#x2F;redbean.dev&#x2F;#lua" rel="nofollow">https:&#x2F;&#x2F;redbean.dev&#x2F;#lua</a>
__derek__over 2 years ago
In case anyone else who&#x27;s played with search engines thinks, &quot;Wait, Okapi sounds familiar,&quot; here you go: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Okapi_BM25" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Okapi_BM25</a><p>The &quot;Get Started&quot; and &quot;View on GitHub&quot; links both have `href=&quot;&#x2F;&quot;`, so they don&#x27;t work.
评论 #33666937 未加载
jbirerover 2 years ago
Thanks, this made me realize how good Haskell is for declaring API routing.
revskillover 2 years ago
Hope the docs for Monad Transformer could be completed for me to understand and use the framework then.
badrabbitover 2 years ago
Haskell for web? That&#x27;s very impressive if you can get it to work at scale. This is the hardest language I have ever personally tried to learn.
评论 #33665352 未加载
评论 #33666414 未加载
评论 #33662879 未加载