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:

Where Next?

Popular Backend topics Top

First poster: bot
Release Introducing rust-gpu v0.1 :dragon: · EmbarkStudios/rust-gpu. Today, we’re releasing a very early version of rust-gpu - a new pro...
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: bot
Today’s the day: We’re very proud to announce Trussed®, an open source framework for modern cryptographic applications, which powers the ...
New
First poster: Carter
https://makepad.dev/ This thread was posted by one of our members via one of our news source trackers.
New
mudasobwa
Tarearbol library that eases the dealing with tasks got a massive update. use Tarearbol.Pool to create worker pools with no boilerplat...
New
First poster: bot
bash-lsp/bash-language-server. A language server for Bash. Contribute to bash-lsp/bash-language-server development by creating an accoun...
New
New
OrlaghNeary
First time posting here and disclaimer, I work with Microsoft! I partner with Microsoft Research and there are so many cool projects unde...
New
First poster: bot
Turn (almost) any Python command line program into a full GUI application with one line
New
First poster: bot
Check if an email address exists without sending any email, written in Rust.
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
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
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New