5 ms·
Okapi – A micro web framework for Haskell
- jbirer 4y agoThanks, this made me realize how good Haskell is for declaring API routing.
- njrc9 4y agoThe author of this framework is also doing very interesting work on building Haskell server pages [1], taking inspiration from redbean's Lua server pages[2]. [1] https://monadic.systems/post7 https://monadic.systems/post7 [2] https://redbean.dev/#lua https://redbean.dev/#lua
- _8j50 4y agoHaskell for web? That's very impressive if you can get it to work at scale. This is the hardest language I have ever personally tried to learn.
- kobalsky 4y agomonads still keep me awake at night
- epgui 4y agoMonads are only complicated if you have to unlearn stuff. You've probably written a ton of monads by accident, regardless of what language you use.
- kobalsky 4y agoexactly, I finally got them when looking at examples in other languages. I never could shake the interest off because I caught a glimpse of god when trying haskell. The language didn't stick on me but I always miss haskell monads.
- naasking 4y agoList comprehensions in multiple languages, LINQ in .NET, all monads.
- tempodox 4y agoAnd all the Computation Expressions in .NET (including the ones you build yourself) are monads.
- aka_dude 4y agoBecause you can't stop thinking how great are they, right? Same
- barbarbar 4y agoAt first I thought you meant Monad Lisa. I will show myself out.
- hestefisk 4y agoHehe
- kccqzy 4y agoOf course you can. As early as 2012, Michael Snoyman has written a book about it, Developing Web Applications with Haskell and Yesod. Yesod is an old web framework by now, but it's not even the oldest. Happstack is even older than that.
- dfee 4y agoDo you write web applications in Haskell? It’s not clear where the community is, and that’s troublesome because for those not well oriented with Haskell, the adventure is solitary. MS seems to be doing a bit of Rust these days, so I kind of wonder if the spiritual successor is another, albeit less hardcore, language. For me, it’s been difficult because I don’t know where the false starts are, and don’t have the unlimited time I once had to wallow and grow without any community support. Other languages are just more approachable, but something eats at me that Haskell is worth it.
- lgas 4y agoNot the person that you're responding to, but I write web applications in Haskell. Previously with Servant and these days mostly with scotty. Happy to try to answer any questions you have here, but there are great communities of helpful people on Reddit (r/haskell and r/haskellquestions) and the FP Slack as well. There's no need to go at it alone. And you're right, Haskell is definitely worth it.
- _huayra_ 4y agoNot PP, but how often do you find yourself tracking down lazy-evaluation / GC-related performance issues? I've heard some horror stories and I honestly don't have the mental model yet to track these things down. Even learning Rust, it still has the same "stack + heap + eager eval" sort of thing as C++. I'm not sure how much of this is done in practice, or if the folks who've had it happen to them are just prolific at internet complaints.
- lgas 4y ago
- MarkMarine 4y agoHave you tried C? I’m not being snarky, remembering all the undefined behavior is a task in itself. I’m a Haskell neophyte, but I often find myself reaching for things haskell has in the box when I’m writing something in another language. To me, it’s like the people who describe a cat as “just like a dog” as a positive trait for the cat. Why deal with the “just like” version if you can have the real thing? Just get a dog. So I find myself reaching for these tools and then I try to just go to the real thing. Unfortunately I can’t run Haskell on an ESP32 :) Btw, this is not to denigrate cats, they are great in their own right. Not for me, I’m violently allergic and somewhat particular to having the things I ensure exist be thankful, but I respect everyone’s choices in the fluffy friend department.
- antonvs 4y ago> somewhat particular to having the things I ensure exist be thankful Sounds like a certain deity
- __derek__ 4y agoIn case anyone else who's played with search engines thinks, "Wait, Okapi sounds familiar," here you go: https://en.wikipedia.org/wiki/Okapi_BM25 https://en.wikipedia.org/wiki/Okapi_BM25 The "Get Started" and "View on GitHub" links both have `href="/"`, so they don't work.
- vector_spaces 4y agoThanks for sharing, although I feel like this is more likely just following the "put a bird on it" trend of naming software frameworks after animals
- revskill 4y agoHope the docs for Monad Transformer could be completed for me to understand and use the framework then.
- rstarast 4y agoThe way this does routing leads to quite hard to read code, compare https://www.okapi.wiki/docs/todo-app https://www.okapi.wiki/docs/todo-app: todoAPI conn = getTodo conn <|> getAllTodos conn with getTodo conn = do methodGET pathParam @Text `is` "todos" todoID <- pathParam @Int ... 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. 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. Quiz question (I don't know the answer): What happens to a request for /todos/foo?
- mark_l_watson 4y agoLooks 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 https://markwatson.com https://markwatson.com). 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.