Haskell IHP framework, from a technical and business perspective
gizra.com
gizra.com
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™... any recommendations?
You can find a couple real-world examples here https://ihp.digitallyinduced.com/Guide/examples.html
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
DerivingViaFrom 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.
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.
It targets programmers that are new to the language, and focuses on the practice of writing Haskell to build projects. Specifically, a blog generator.
I tend to focus more on building things than the theory and hope that folks are seeing the practical side of programming in Haskell.
Fractal renderer: https://github.com/serprex/Fractaler Templates.hs implements a variety of fractals as pure functions & Fractaler.hs is the UI
Brainfuck interpreter: https://github.com/serprex/bfhs minibf.hs is half the size of bf.hs, but the latter is more optimized as it implements jump tables for [] instructions & combines consecutive <>+- & more. Tape implemented as a zipper. Fun part of implementation is that the interpreter is mostly a pure function building up an output string & returns that to the io interpreter when it needs input or escaping
> 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?
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).
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 :)
{ 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.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...).
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.
For me personally when I look at Elixir/OTP vs Haskell it breaks down to this; concurrency/parallelism/scaling, laziness (Haskell), syntax (H minimal vs E Ruby-esque) and types (H static, E dynamic). These are what I personally notice between them and I could be wrong with my interpretation because I don't work with Haskell/Elixir but merely watch/read content on them.
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".
For me, it is the same as to have a server in Mathlab.
Also, like I said, the code I am unreadable J2EE like mess of useless, redundant abstractions.