CommunityNews

CommunityNews

IHP – A Haskell web framework

IHP is a modern batteries-included haskell web framework, built on top of Haskell and Nix.

We believe that functional programing is the future of software development and want to make functional programing with haskell and nix available to anyone. We try to offer a solution which can be used by developers who have not worked with haskell yet. IHP comes with everything you need to build great web applications with haskell and nix. We have made a lot of pragmatic decision to get you started faster. This way you can just pick up haskell along the way :slight_smile:

IHP stands for Integrated Haskell Platform.

This thread was posted by one of our members via one of our automated news source trackers.

Most Liked

SmithyTT

SmithyTT

Example controller

module Web.Controller.Posts where

import Web.Controller.Prelude
import Web.View.Posts.Index
import Web.View.Posts.New
import Web.View.Posts.Edit
import Web.View.Posts.Show
import qualified Text.MMark as MMark

instance Controller PostsController where
    action PostsAction = do
        posts <- query @Post
            |> orderByDesc #createdAt
            |> fetch
        render IndexView { .. }

    action NewPostAction = do
        let post = newRecord
        render NewView { .. }

    action ShowPostAction { postId } = do
        post <- fetch postId
            >>= pure . modify #comments (orderByDesc #createdAt)
            >>= fetchRelated #comments
        render ShowView { .. }

    action EditPostAction { postId } = do
        post <- fetch postId
        render EditView { .. }

    action UpdatePostAction { postId } = do
        post <- fetch postId
        post
            |> buildPost
            |> ifValid \case
                Left post -> render EditView { .. }
                Right post -> do
                    post <- post |> updateRecord
                    setSuccessMessage "Post updated"
                    redirectTo EditPostAction { .. }

    action CreatePostAction = do
        let post = newRecord @Post
        post
            |> buildPost
            |> ifValid \case
                Left post -> render NewView { .. } 
                Right post -> do
                    post <- post |> createRecord
                    setSuccessMessage "Post created"
                    redirectTo PostsAction

    action DeletePostAction { postId } = do
        post <- fetch postId
        deleteRecord post
        setSuccessMessage "Post deleted"
        redirectTo PostsAction

buildPost post = post
    |> fill @["title","body"]
    |> validateField #title nonEmpty
    |> validateField #body nonEmpty
    |> validateField #body isMarkdown

isMarkdown :: Text -> ValidatorResult
isMarkdown text =
    case MMark.parse "" text of
        Left _ -> Failure "Please provide valid Markdown"
        Right _ -> Success

Lot of unusual looking syntax :man_shrugging:

AstonJ

AstonJ

Just watching this now… looks pretty neat (and different!) you add tables and columns via the web gui - you even create controllers via it, don’t think I’ve seen that in a web framework before:

Popular Backend topics Top

First poster: bot
RuboCop 1.0. If at first you don’t succeed, call it version 1.0. RuboCop’s development started exactly 7 and half years ago. I made the ...
New
First poster: bot
Pijul - The Mathematically Sound Version Control System Written in Rust. In this article, we’ll discuss Pijul - an alpha stage version c...
New
New
First poster: bot
Why is it called pie? Because if you pronounce API like “a pie”, then all this consuming and serving of APIs becomes a lot more palatabl...
/go
New
First poster: Carter
https://makepad.dev/ This thread was posted by one of our members via one of our news source trackers.
New
First poster: bot
A little over a year ago I created the rib static site generator in Haskell based on Shake and ghcid. Later that year I built Neuron (...
New
First poster: bot
Maddy Mail Server implements all functionality required to run a e-mail server. It can send messages via SMTP (works as MTA), accept mess...
New
CommunityNews
Rhizome is a paedagogical just-in-time compiler (JIT) for Ruby, implemented in pure Ruby. It’s not really designed to be used. It’s desig...
New
mudasobwa
Md, a library to parse markdown and markdown-like syntaxes, has been released. Fully-customizable syntax, blazingly fast (5× compared to...
New
dhoelzgen
I am currently giving Cursor another try to code Elixir apps. Although I am quite happy with how it evolved, I kept getting annoyed by th...
New

Other popular topics Top

AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New