[HN Gopher] Haskell IHP framework, from a technical and business...
       ___________________________________________________________________
        
       Haskell IHP framework, from a technical and business perspective
        
       Author : _query
       Score  : 84 points
       Date   : 2021-11-11 13:02 UTC (9 hours ago)
        
 (HTM) web link (www.gizra.com)
 (TXT) w3m dump (www.gizra.com)
        
       | cosmic_quanta wrote:
       | I learned a lot about building Haskell web apps by studying the
       | following source code:
       | 
       | https://github.com/restyled-io/restyled.io
        
       | phaer wrote:
       | I am confused, the text says:
       | 
       | > The subject of the mail will change based on the status of the
       | Reservation. With the type system in place, the compiler makes
       | sure we that do not forget any possible case.
       | 
       | But the [linked code](https://github.com/Gizra/ihp-simple-seat-
       | reservation/blob/f9...) seems to include a wildcard clause which
       | would just set the subject to an empty string. Am I missing
       | something?
        
         | HowardStark wrote:
         | The important point isn't that there's a wild card, it's that
         | there isn't an undefined clause. You know with compiler-assured
         | certainty that WYSIWYG, which is a big step in code
         | predictability.
        
           | phaer wrote:
           | Could you elaborate? Wouldn't it be better to i.e. throw a
           | runtime error than to send an email with an empty subject to
           | a user from a business perspective in most cases?
        
             | amitaibu wrote:
             | I tried to keep the code simple, so yeah - it was on the
             | expense of making it more "right".
             | 
             | In this case I wouldn't call the command send the mail
             | unless status was explicitly Accepted or Rejected.
             | 
             | But as notes above, the important part is that the compiler
             | doesn't let me forget about all the possible cases (e.g.
             | `Queue` in this example).
        
       | leetrout wrote:
       | I tried Haskell a decade ago and gave up pretty quick due to some
       | of the stereotypical reasons.
       | 
       | I really like this test file the author linked to for a great
       | example of what "real" haskell can look like.
       | 
       | https://github.com/Gizra/ihp-simple-seat-reservation/blob/ma...
       | 
       | I'm interested in other "pragmatic" haskell sources / tutorials
       | that lose the ego / pretentiousness and demonstrate Getting Stuff
       | Done(tm)... any recommendations?
        
         | res0nat0r wrote:
         | I bought the PDF, and now physical book of this, it's massive
         | and really good: https://haskellbook.com/
        
         | agentultra wrote:
         | I should probably write more but this is what I do on my stream
         | at https://twitch.tv/agentultra -- we've built a streaming
         | replication library for PostgreSQL (from scratch all the way up
         | to released package) and are presently exploring different
         | native GUI frameworks.
         | 
         | I tend to focus more on building things than the theory and
         | hope that folks are seeing the practical side of programming in
         | Haskell.
        
         | rgoulter wrote:
         | I like the term 'simple haskell' more. It links to a few
         | blogposts with similar sentiments. http://simplehaskell.org/
        
           | lalaithion wrote:
           | The file linked is not what the 'simple Haskell' philosophy
           | suggests. It is compiled with the following extensions
           | enabled:                   OverloadedStrings
           | NoImplicitPrelude         ImplicitParams         Rank2Types
           | DisambiguateRecordFields         NamedFieldPuns
           | DuplicateRecordFields         OverloadedLabels
           | FlexibleContexts         TypeSynonymInstances
           | FlexibleInstances         QuasiQuotes         TypeFamilies
           | PackageImports         ScopedTypeVariables
           | RecordWildCards         TypeApplications         DataKinds
           | InstanceSigs         DeriveGeneric
           | MultiParamTypeClasses         TypeOperators
           | DeriveDataTypeable         MultiWayIf
           | UndecidableInstances         BlockArguments
           | PartialTypeSignatures         LambdaCase
           | DefaultSignatures         EmptyDataDeriving
           | BangPatterns         BlockArguments         MultiWayIf
           | FunctionalDependencies         PartialTypeSignatures
           | StandaloneDeriving         DerivingVia
        
             | rgoulter wrote:
             | Most of those feature in this list of recommended defaults
             | https://github.com/commercialhaskell/rio#language-
             | extensions which is cited as an example in simplehaskell's
             | page on recommendations.
             | https://www.simplehaskell.org/language-extensions.html
             | 
             | From what I've touched of Haskell, I'd think e.g.
             | OverloadedStrings makes Haskell simpler to use than leaving
             | it out. (And OverloadedStrings certianly doesn't seem ego-
             | inducing).
             | 
             | Simple Haskell's page on extensions also isn't advocating
             | for anything too concrete. Just an emphasis on pragmatic,
             | simple to maintain code.
             | 
             | IHP's landing page even claims "Don't worry, you don't need
             | to know much about Haskell to get started, you'll learn it
             | along the way". This seems to be in the spirit of simple
             | Haskell, although I'd be curious to hear about what parts
             | seem not-simple.
        
               | dwohnitmok wrote:
               | The extensions that aren't on that list but are in the
               | list provided by lalaithion are pretty "big" extensions
               | that can severely increase the bar needed to understand
               | Haskell code (I'm looking at ImplicitParams, QuasiQuotes,
               | DataKinds, TypeOperators, and UndeciableInstances).
               | 
               | In general, I've only read over IHP code, but never used
               | it myself, I'd be worried about the quality of GHC error
               | messages for a Haskell novice with the amount of magic
               | IHP is providing.
               | 
               | There's some nifty type-level programming going on in the
               | background with IHP which works great when everything
               | compiles, but can have confusing GHC error messages if
               | you have an error.
        
         | _query wrote:
         | Here's a link to the IHP Chat Example app:
         | https://github.com/digitallyinduced/ihp-chat-example-app/blo...
         | 
         | You can find a couple real-world examples here
         | https://ihp.digitallyinduced.com/Guide/examples.html
        
         | gilmi wrote:
         | I've recently released a (fairly complete by still alpha
         | version) project-oriented Haskell ebook[0].
         | 
         | It targets programmers that are new to the language, and
         | focuses on the practice of writing Haskell to build projects.
         | Specifically, a blog generator.
         | 
         | [0]: https://lhbg-book.link
        
       | lngnmn2 wrote:
       | It is useless to say, but Haskell is a modeling and domain
       | language, it is a sunset of math and highly sugared logic.
       | 
       | The proper place if Haskell code is Fastcgi and batch processing.
       | 
       | It should FFI everything infrastructure related and should be
       | called by nginx or whatever.
       | 
       | Using it as a Java EE with monads is plain, well, let's say
       | "over-engineering".
        
         | chowells wrote:
         | You have never used Haskell, have you?
        
         | thewakalix wrote:
         | If it's useless to say, why did you say it?
        
           | rizky05 wrote:
           | Some people like being useless.
        
       | dustingetz wrote:
       | The web framework landing page: https://ihp.digitallyinduced.com/
        
       | yumraj wrote:
       | There may not be an easy answer, but could someone opine on how a
       | Haskell/IHP based web application would compare with
       | Elixir/Phoenix based solution.
       | 
       | I'm primarily interested in Haskell vs Erlang/Elixir comparison
       | rather than IHP vs Phoenix, since I'm aware that Phoenix may be
       | more featured at the moment.
        
       | tromp wrote:
       | Is it possible to use IHP without installing Nix? I already have
       | brew as general package manager and ghcup/cabal as Haskell
       | toolchain/library manager and dread having yet another package
       | manager that might interfere...
        
         | _query wrote:
         | It's not possible to use IHP without Nix. Using nix allows us
         | to make fully reproducable dev environments as all versions
         | (even e.g. the version of postgres used in dev mode) are pinned
         | down.
         | 
         | The IHP docs assume no knowledge about nix, so it should still
         | mostly be very simple to get started.
         | 
         | We compiled a couple more reasons why IHP uses nix in this blog
         | post: https://ihp.digitallyinduced.com/blog/2020-07-22-why-ihp-
         | is-...
         | 
         | Btw: To give IHP a try without installing Nix you can also try
         | out the official GitPod image here
         | https://gitpod.io/#https://github.com/gitpod-io/template-ihp :)
        
         | iammisc wrote:
         | > dread having yet another package manager that might
         | interfere...
         | 
         | Nix won't and can't interfere with your system
        
         | rgoulter wrote:
         | Although I see nix is required, it would be possible to run the
         | ihp-new program with just nix installed, but without needing to
         | change your PATH permanently. e.g. with a shell.nix file with
         | contents:                 { pkgs ? import <nixpkgs> {} }:
         | let         ihp-new = pkgs.fetchzip {           url =
         | "https://downloads.digitallyinduced.com/ihp-new.tar.gz";
         | sha256 =
         | "0prpw46iyrjwzglq38n4kfn68dv2piw6dn8464ra99yl1dml465m";
         | };       in       pkgs.mkShell {         packages =
         | [pkgs.cachix ihp-new];       }
         | 
         | Running nix-shell with this would download the ihp-new program,
         | and you'd have access to it (and postgres, etc., when you run
         | with a shell with direnv enabled), but outside of the nix-
         | shell, your PATH and other things would be unaffected.
        
           | _query wrote:
           | The ihp-new command is only a shell script that does a few
           | checks and then git clones the project boilerplate:
           | 
           | https://github.com/digitallyinduced/ihp/blob/master/ProjectG.
           | ..
           | 
           | The actual IHP project has it's own nix-shell environment, so
           | that all project dependencies are managed locally
           | (https://github.com/digitallyinduced/ihp-
           | boilerplate/blob/mas...).
        
       ___________________________________________________________________
       (page generated 2021-11-11 23:02 UTC)