IHP Release: 27.11.2020

It's time for the next release of IHP: v20201030 🎉 This release mainly focus on improving existing functionality and making things more stable :) Since the last release we also reached an important milestone: IHP is now the second biggest haskell framework measured by GitHub stars - just 5 months after it's initial public release. The future of haskell web dev is happening right here 🚀

Major Changes

Other Changes

Updating

See the UPGRADE.md for upgrade instructions.


If you have any problems with updating, let us know on the IHP forum. Or join our new slack.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 11.12.2020.

marc , in General
Compile error on 'StaticControllerinstance'

Hi,

I'm following the First App tutorial and I'm running into this error when creating a controller named 'Posts'.

What could have gone wrong? And how can I get going again?

To reproduce:

  • sudo ihp-new blog
  • sudo chown -R user:users blog/
  • cd blog
  • ./start
  • Create DB model and press 'Update DB';
  • Enter Code-gen; add controller 'Posts', preview; -- up to here all goes well
  • press 'Generate' and the compile window gives compile errors.
[ 5 of 19] Compiling Web.Types        ( Web/Types.hs, interpreted )
[ 6 of 19] Compiling Web.Routes       ( Web/Routes.hs, interpreted )

Web/Routes.hs:7:20: error:
    Not in scope: type constructor or class ‘StaticControllerinstance’
  |
7 | instance AutoRoute StaticControllerinstance AutoRoute PostsController
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^
[ 7 of 19] Compiling Web.Controller.Prelude ( Web/Controller/Prelude.hs, interpreted ) [Web.Types changed]
Failed, six modules loaded.

I'm running on Nixos.

Here's the output of ihp-troubleshoot:

$ bash ihp-troubleshoot
Checking that the current directory is an IHP project:
+ Found Main.hs
+ Found start
Checking nix:
+ Nix installed
Checking direnv:
+ Found .envrc
+ direnv loads .envrc
+ ghci is loaded from nix store
Checking .ghci:
+ Found .ghci
+ .ghci permissions are ok
Checking IHP:
+ Symlink build/ihp-lib exists
+ Symlink build/ihp-lib target exists
+ IHP used from nix
Checking Cachix:
- Cachix config is missing. Is cachix installed?
cat: /home/user/.config/nix/nix.conf: No such file or directory
- digitallyinduced.cachix.org binary cache missing. Try 'cachix use digitallyinduced'
cat: /home/user/.config/nix/nix.conf: No such file or directory
+ No legacy cachix key found
Debugging Details:
GHCI Output:
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /home/user/ihp/blog2/.ghci
IHP> ok
IHP> Leaving GHCi.
build/ihp-lib Target:
/nix/store/gdlksfh4afv3dk8wkcmwsn670rf5kjkl-ghc-8.8.3-with-packages/lib/IHP
Direnv Output:
direnv exec path /nix/store/c6sh3476va60wqck3iam87vbj93k34rg-direnv-2.21.2-bin/bin/dir\
env
DIRENV_CONFIG /home/user/.config/direnv
bash_path /nix/store/xadrr3l5jvkkm3g3lb2g81j5wz51zqdv-bash-interactive-4.4-p23/bin/bas\
h
disable_stdin false
warn_timeout 5s
whitelist.prefix []
whitelist.exact map[]
Loaded RC path /home/user/ihp/blog2/.envrc
Loaded watch: ".envrc" - 2020-10-31T16:46:21+01:00
Loaded watch: "../../.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089bf6f3a8f3c\
b69b08b9f7ed4427f70bc67fa" - 2020-10-31T16:46:21+01:00
Loaded RC allowed false
Loaded RC allowPath
Found RC path /home/user/ihp/blog2/.envrc
Found watch: ".envrc" - 2020-10-31T16:46:21+01:00
Found watch: "../../.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089bf6f3a8f3cb\
69b08b9f7ed4427f70bc67fa" - 2020-10-31T16:46:21+01:00
Found RC allowed true
Found RC allowPath /home/user/.local/share/direnv/allow/dc29e63ea60b0ec67c0788bfb8089b\
f6f3a8f3cb69b08b9f7ed4427f70bc67fa
which direnv Output:
/nix/store/gdlksfh4afv3dk8wkcmwsn670rf5kjkl-ghc-8.8.3-with-packages/bin/ghci
default.nix:
let
    ihp = builtins.fetchGit {
        url = "https://github.com/digitallyinduced/ihp.git";
        rev = "a8030dd1e4041a0353f63d03b4ffb836cb2bd95c";
    };
OS:
Linux
hansw , in General
IHP Release: 30.10.2020

It's time for the next release of IHP: v20201030 🎉 This release mainly focus on improving existing functionality and making things more stable :)

Major Changes

Other Changes

Updating

First open default.nix and change the git commit in line 4 to the following:

rev = "a8030dd1e4041a0353f63d03b4ffb836cb2bd95c";

After that run the following command to update your project:

nix-shell -j auto --cores 0 --run 'make -B .envrc'
make -B build/ihp-lib

Now you can start your project as usual with ./start.


Aside from all the code changes above we've also updated the IHP website: https://ihp.digitallyinduced.com/ :) First big refresh after IHP has been published around 4 months ago.

If you have any problems with updating, let us know on the IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 13.11.2020.

marc , in General
IHP Release: 16.10.2020

It's time for the next release of IHP: v20201016 🎉

Major Changes

Other Changes

Updating

This release requires a few more steps than usual. As we've changed the nixpkgs version, this will also require a lot of redownloading of all packages. Make sure you have good internet and can wait up to 30 minutes to complete the download. We highly suggest to make sure your coffee machine is working before starting the update.

First open default.nix and change the git commit in line 4 to the following:

rev = "49816c21d34fd7894a956bf7fd997e6ed5243acf";

Open Config/nix/nixpkgs-config.nix and replace the file with this new version: https://raw.githubusercontent.com/digitallyinduced/ihp-boilerplate/81518e9b66e1e9d3bdf40affa674a7d2cd63f414/Config/nix/nixpkgs-config.nix

After that run the following command to update your project:

# Be aware that this will redownload a lot of files and take lots of time
nix-shell -j auto --cores 0 --run 'make -B .envrc'
make -B build/ihp-lib

# This step is required to get the config files for haskell-language-server
make hie.yaml

Now you can start your project as usual with ./start.

Check out the docs to get started with haskell language server to get cool IDE features.


If you have any problems with updating, let us know on the IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 30.10.2020.

marc , in General
Problems using composite primary keys

I'm trying to model a many-to-many relationship with containers containing items which can belong to multiple containers with the help of a container_items table defined like so:

CREATE TABLE container_items (
    container_id UUID NOT NULL,
    item_id UUID NOT NULL,
    PRIMARY KEY (container_id, item_id)
);

But I get errors in the Generated/Types.hs file about Couldn't match type ‘Id' "items"’ with ‘UUID’ .

build/Generated/Types.hs:41:30: error:
    • Couldn't match type ‘Id' "items"’ with ‘UUID’
        arising from a use of ‘QueryBuilder.filterWhere’
    • In the third argument of ‘Item’, namely
        ‘(QueryBuilder.filterWhere
            (#itemId, id) (QueryBuilder.query @ContainerItem))’
      In the second argument of ‘($)’, namely
        ‘Item
           id
           name
           (QueryBuilder.filterWhere
              (#itemId, id) (QueryBuilder.query @ContainerItem))
           def’
      In a stmt of a 'do' block:
        pure
          $ Item
              id
              name
              (QueryBuilder.filterWhere
                 (#itemId, id) (QueryBuilder.query @ContainerItem))
              def
   |
41 |         pure $ Item id name (QueryBuilder.filterWhere (#itemId, id) (QueryBuilder.query @ContainerItem)) def
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^build/Generated/Types.hs:41:30: error:
    • Couldn't match type ‘Id' "items"’ with ‘UUID’
        arising from a use of ‘QueryBuilder.filterWhere’
    • In the third argument of ‘Item’, namely
        ‘(QueryBuilder.filterWhere
            (#itemId, id) (QueryBuilder.query @ContainerItem))’
      In the second argument of ‘($)’, namely
        ‘Item
           id
           name
           (QueryBuilder.filterWhere
              (#itemId, id) (QueryBuilder.query @ContainerItem))
           def’
      In a stmt of a 'do' block:
        pure
          $ Item
              id
              name
              (QueryBuilder.filterWhere
                 (#itemId, id) (QueryBuilder.query @ContainerItem))
              def
   |
41 |         pure $ Item id name (QueryBuilder.filterWhere (#itemId, id) (QueryBuilder.query @ContainerItem)) def
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I can get this to work if I have an id column as a pkey on container_items but should that be necessary? Not sure what I'm doing wrong here.

twahtera , in Database
IHP Release: 02.10.2020

It's time for the next release of IHP: v20201002 🎉

Major Changes

Other Changes

- The image upload recipe has been extended to document how the form needs to look when doing image uploads. - Login error messages are now Invalid credentials - Generated.Types is imported by default in the empty Layout.hs - The Contributing documentation now explains how to run the IHP tests - A bug where the FrontController.hs was generated twice was fixed - The version of morphdom used by IHP has been updated - A new textToId function has been added to simplify conversion of text or bytestrings to db ids - Missing documentation on fetchCount has been added - New recipe: How to generate a random string - New function: sqlQueryScalar similiar to sqlQuery but returns a scalar value - Fixed scripts not working in dev mode - Fixed awk warning when running make static/prod.js

Updating

To update the IHP version of your project, open default.nix and change the git commit in line 4 to the following:

rev = "c4d2815f064c055cd957389a4df5eab25294dba3";

After that run the following command to update your project:

nix-shell -j auto --cores 0 --run 'make -B .envrc'

Now you can start your project as usual with ./start.


If you have any problems with updating, let us know on the IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 16.10.2020.

If you haven't looked already, check out the IHP Auto Refresh Demo 🚀

marc , in General
Badges

"We don't need no stinking badges!" Haha just kidding. Of course we do! I'm just putting up a link to a PR related to the forum badges in case anyone has any comments/suggestions/improvements.

montmorency , in IHP Forum
New Release: Beta 18.09.2020

It's time for the next release of IHP: 20200918 🎉

Major Changes

Other Changes

Updating

To update the IHP version of your project, open default.nix and change the git commit in line 4 to the following:

rev = "0575a933331d45782ed732a5437ead377e165b29";

After that run the following command to update your project:

nix-shell -j auto --cores 0 --run 'make -B .envrc'

Now you can start your project as usual with ./start.


If you have any problems with updating, let us know on the IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 02.10.2020.

Also a short update on IHP Cloud: We've been busy onboarding new users the last couple of days :) The first apps deployed to IHP Cloud look really cool. We're super excited 🚀

marc , in General
HSX: Conversion from Action to Route through ToHtml?

I started learning IHP and after finishing the "Your first project" part in the IHP Guide, I saw how actions where used as routes in two ways:

  • <a href={pathTo NewPostAction}><...
  • <a href={ShowPostAction}><...

Changing any of them to the other breaks neither of them

Now, looking at the HSX Guide, it states:

"If the variable is any other custom Haskell data structure: it will first be converted to a string representation by calling show on it. You can add a custom ToHtml (import it from IHP.HtmlSupport.ToHtml) instance, to customize rendering a data structure."

As I looked at the ToHtml class, I reasoned it should probably work in the way, that if there is no ToHtml Instance for a "custom haskell data structure", it will just use the Show instance of ToHtml, which is derived for any generated Controller Actions. I figured, this must mean in the conversion process from hsx to html, there is no explicit use of Show but ToHtml is used for any data, defaulting to its Show instance.

If I'm right, does that mean, that there are generated ToHtml instances for the Controller Actions, which would convert them? A derived Show instance of a normal algebraic data structure would just return the typical string representation said structures, so there must be a conversion to a href-compatible path. I couldn't find the ToHtml instances, but still with or without pathTo, the action gets translated to a path in HSX(Maybe I'm wrong here?). pathTo's usage would be to manually change a path, and if no change of the path is needed, one can just write "{Action}" to get the standard path to it.

Maybe I misunderstand something crucial here, and I would be happy to change that. My future self thanks you!

smorfer , in General
IHP Release: 04.09.2020 (v20200904)

It's time for the next release of IHP: 20200904 🎉

Major Changes

  • Composite Primary Key Support: You can now use tables that have a primary key consisting of multiple columns. This helps you to handle complex database schemas with IHP. To use this new feature, just define a composite PK in your Schema.sql like this:
CREATE TABLE order_trucks (
    order_id BIGSERIAL NOT NULL,
    truck_id BIGSERIAL NOT NULL,
    PRIMARY KEY(order_id, truck_id)
);

This feature has been contributed by @ruhatch 🎉

  • Improved Error Screen when a request parameter is missing: Errors caused by calls to param now have a beautiful error screen telling you about what do next. It also displays all submitted params, so you can quickly spot whether there was a typo.

Other Changes

- The primary haskell json library aeson is now exported by the ViewPrelude by default. No need to manually import it in your views anymore. - A code generation issue caused by having a table with two foreign keys referencing the same foreign table has been fixed. - An issue encoding with enums using multibyte characters has been resolved - The CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; is not required in your app's Schema.sql anymore. It's automatically loaded by IHP. - Support for empty attributes in HSX like <input disabled/> has been added. - Grammar fixes - The make target build/bin/RunOptimizedProdServer now correctly depends on build/Generated/Types.hs. The target build/bin/RunUnoptimizedProdServer already has this dependency. - Dotless Emails are now validated correctly - All IHP binaries are now compiled with -threaded. Somehow we missed this. This improves the performance of the dev server. - The default ghci prompt of a IHP is now a lambda symbol - make targets for compiling IHP scripts have been added - a naming issue causing request not being easily useable in actions has been resolved

  • The release versioning scheme has changed from vDDMMYYYY to vYYYYMMDD starting with this version.

Updating

To update the IHP version of your project, open default.nix and change the git commit in line 4 to the following:

rev = "a12a1ce8f16814b802aae39eb26a9d3247192c12";

After that run the following command to update your project:

nix-shell -j auto --cores 0 --run 'make -B .envrc'

Now you can start your project as usual with ./start.


In case you get a compiler error about a missing field in ModelContext in the auto-generated build/Generated/Types.hs please stop your application and do a clean rebuild:

make clean
nix-shell -j auto --cores 0 --run 'make -B .envrc'
./start

If you have any problems with updating, let us know on the brand new IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 18.09.2020.

Also a short update on IHP Cloud: We're sending out the first IHP Cloud invites in the coming days 🔥

marc , in General
IHP Release: 21.08.2020 (v21082020)

We've just released a new IHP version! :)

Major Changes

  • Numeric Primary Keys Supported: IHP now allows numeric (Serial in Postgres-speak) primary keys. Previously only UUIDs have been supported. UUIDs will still be the default. This feature makes it more simple to use IHP with existing databases and services.
  • nl2br: A new view helper has been added in this release. With nl2br you can transform \n linebreaks to <br> line breaks. Like get #body post |> nl2br :)
  • HTML Comments: HSX now supports HTML comment syntax. <!-- 🚀 -->. This has been added after someone asked for comment syntax on Stack Overflow. This was actually the first IHP-related stack overflow question we've come across.

Other Changes

Updating

To update the IHP version of your project, open default.nix and change the git commit in line 4 to the following:

rev = "0bb881e0febdf5fb8db939a6c5eb481c76a1b332";

After that run the following command to update your project:

nix-shell -j auto --cores 0 --run 'make -B .envrc'

In case nix starts rebuilding IHP (might take a while), make sure cachix is set up as expected:

cachix use digitallyinduced

Now you can start your project as usual with ./start.

If you have any problems with updating, let us know on the brand new IHP forum.

📧 To stay in the loop, subscribe to the IHP release emails. Or follow digitally induced on twitter..

📅 The next release is expected to be released on 04.09.2020.

If you're curious what we're also working on, click here 🔥

marc , in General