I'm finding the live loading in the browser sometimes dies while I'm editing the code. My setup is on MacOs Mojave/Firefox and I'm editing the haskell code directly using VI/nerdtree. The IHP development server is still running but I'm getting a log of: StatusServer: Cannot stop as not running and the page formatting in the browser isn't updating.Is there a simple way of restarting the Server without killing the development environment and running the start script again?
I was just wondering if an "IHP Forum" Topic would be a good idea? That way any suggestions/improvements for the IHP Forum could be discussed there. It might also be a place to raise small bug fixes that are too small to justify a pull request? E.g. I noticed in the EditView thread body is a "textField" rather than a "textareaField" which makes fixing posts tricky.
We've just released a new IHP version! :)
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
you can transform \n
linebreaks to <br>
line breaks. Like get #body post |> nl2br
:)
<!-- π -->
. 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.
ParamReader Float
and InputValue Float
instances have been added for better dealing with Float values
ToJson
instance for IHP record Ids
findLibDir
causing trouble with production deployments
import
statements twice
Generated.Types
ParamReader
instance by default. This makes it easier to work with enums in forms.
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 π₯
It's time for the next release of IHP: 20200904 π
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 π
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.
SQL Logging only in dev mode: IHP will now not log sql queries when it's running in production mode.
Improved Data Tool in the Dev Tooling: The database access tool (below the Schema Editor in the IHP navigation) now makes more efficient use of screen space. We made a few small changes to improve the overall usability of the tool.
More documentation:
- 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
vDDMMYYYY
to vYYYYMMDD
starting with this version.
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 π₯
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:
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!
It's time for the next release of IHP: 20200918 π
query @User |> orderBy #firstname |> orderBy #lastname
. Previously the last call to orderBy #lastname
would overwrite the existing orderBy #firstname
. This has been added by @fegu π
error: file '/build/db/.s.PGSQL.5432' has an unsupported type
when starting IHP has been fixed by @ruhatch ! π This error happend when opening a new nix shell while the dev server is running.
getSessionAndClear
: Returns a session value and removes it from the session
getRequestUrl
has been renamed to getRequestPath
to better reflect it's behavior. Also a new getRequestPathAndQuery
has been added.
jsonb
: You can now easily store json inside your postgres with your IHP app. Right now this is just very basic support. Additional support for mapping the json will be added in the future. Currently you need to manually map it using aeson.
toSlug
: toSlug "IHP Release: 18.09.2020"
will turn the string into a url friendly version "ihp-release-18-09-2020"
.
fetchOne
fails because no result was returned
dateTime
is now working correctly in all locals :) Thanks @dansvo!
fetchExists
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.
It's time for the next release of IHP: v20201002 π
Realtime UI Updates with IHP AutoRefresh: Whenever a INSERT
, UPDATE
or DELETE
happens to the records used by your action IHP will rerun your action on the serverside. When the generated html looks different to the html generated on the initial page load it will send the new html to the browser using the WebSocket connection. Watch a demo on twitter or Learn more in the Auto Refresh documentation.
PGNotify Functions: A new module has been added to easily watch for changes inside the database.
Fancy Errors Disabled in Production: The IHP error handler that tries to be helpful when something goes wrong is now disabled by default in production.
New function: paramList: Similiar to param
but returns a list when the input is something like ingredients=milk&ingredients=egg
. Useful when working with checkboxes.
LIMIT queries: You can now add LIMIT
to your sql queries easily when using the query builder:
topTen <- query @Post
|> orderBy #rating
|> limit 10
|> fetch
Postgres Arrays: We've added support for types such as int[]
or text[]
. These types are not visible in the web-based dev tools yet, but can be used manually when using a code editor to edit the Schema.sql
.
New Terminal Command: hash-password: With this new terminal tool you can generate a password hash when setting up the IHP authentication module. It will ask your for the plaintext password and will output the password hash.
collectionFetchRelated works with QueryBuilder: Previously collectionFetchRelated
was not working with certain relationships. This has been fixed and the below code will now work as expected:
posts <- query @Post
|> fetch
>>= collectionFetchRelated #comments
- 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
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 π
I have the latest version of VS Code (on Ubuntu Linux) and I am trying to follow the instructions in the recent video about Haskell integration to VS code. But when I try to get the command to set the environment variable as described in the video, there is no command available in the drop down as shown in the video. The written documentation linked to from the video does not deal with this.
It's time for the next release of IHP: v20201030 π This release mainly focus on improving existing functionality and making things more stable :)
Database Connection Pool: IHP now comes with a new database connection pool. This allows for better scalability and performance when dealing with many queries. It also makes IHP more reliable: In previous versions of IHP, a long running database connection might be closed by the database server when nothing happens for too long. This issue will not happen anymore with the new db connection pool.
Live Reloading Improvements: A bug has been fixed that caused the live reloading not to work when a file was changed. Additionally the web-based compiling status view has been rewritten to be more efficient (you can really feel that it's faster now).
LocalTime Support: Support for TIMESTAMP WITHOUT TIME ZONE
has been added. It works similiar to the normal timestamp you already know from IHP, but doesn't store any Timezone information.
Welcome Page In Project: When generating a new IHP project, the project now contains the initial welcome action as part of the project code. This allows to for more play when just starting out, because now you can just change the welcome view as you like :)
Basic Auth: Finally you can have basic auth prompts in IHP. You can use it like this:
instance Controller WidgetsController where
beforeAction = basicAuth "sanja" "hunter2" "myapp"
This requires the user to enter sanja
with password hunter2
when trying to access the WidgetsController
. Check the documentation for details.
Schema.sql
INSERT, UPDATE, DELETE
queries now work in the custom sql query box inside the IHP Data Editor
Schema.sql
. This avoids issues where a CREATE TABLE
statements uses an enum that hasn't been defined yet.
data-confirm
: <a href={DeleteProjectAction} data-confirm={"Do you really want to delete" <> get #name project <> "?"}>Delete project</a>
js-delete
for your link.
ihp-new
now sets the correct permissions to the .ghci
when starting a new project. This has caused troubles in the past for some new users
.stylish-haskell
config file that's part of all IHP projects by default has been updated to work again with the latest IHP version
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.
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:
[ 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
It's time for the next release of IHP: v20201016 π
Haskell Language Server Support: You can now get cool IDE features by using Haskell Language Server. It works mostly out of the box after updating to this IHP version. Check out the documentation on how to get it running with your fav editor.
Updated NixPkgs Version: We're updating the IHP package set to a newer version. We're moving from da7ddd822e32aeebea00e97ab5aeca9758250a40
to 07e5844fdf6fe99f41229d7392ce81cfe191bcfc
. This means some of your dependencies might get updated.
OFFSET Support: You can now easily use Postgres OFFSET
with the query builder:
query @User
|> limit 25
|> offset 50
|> fetch
New Form Helper: numberField
: Similiar to textField
, renders a <input type="number"/>
.
formFor project [hsx|
{numberField #maxUsersLimit}
|]
Automatic Troubleshooting: We've created a script that checks all common issues that often go wrong when setting up IHP (like direnv
issues, .ghci
permission issues, etc.). When you cannot run your IHP app anymore, run the troubleshooting to find out possible error conditions. You can find more in the Troubleshooting section.
Sending Emails: Support for sending mails has been added in this release. Use the new code generator to get started π₯
param @Bool
now accepts true
as a truthy value.
HttpOnly
and secure
(only if app is served via https) now
beforeLogin
callback. This can be useful to abort the login process when a user is not yet confirmed.
urlTo
can now be used everywhere where pathTo
is used
stripTags
function has been added to HaskellSupport
. This function removes all html tags from an input string.
Uploading a user profile picture
now mentions that the picture_url
should be nullable
Id
values such as Id Project
now have Ord
and Hashable
instances by default
Data
Tool have been fixed. E.g. adding a row works again now.
Using IHP with Emacs
has been added
Using IHP with Vim
has been added
textToId
function now also works with text primary keys. Previously it only worked with UUIDs.
postgresql-simple
Only
wrapper is now exported to all controllers
BYTEA
) column in a table
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.
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 π
Update DB
will now be displayed in a more useful way. Previously the error message just displayed the full postgresql output in a single line. Now the error message is displayed like this: tailwindcss
into your IHP projects. You can find the guide here: https://ihp.digitallyinduced.com/Guide/tailwindcss.html
How many people are running at which IHP version? What is the primary OS people are using IHP on? How many active users are working with IHP?
we added Telemetry to the local dev server that runs when you call ./start
. The dev server reports ihpVersion
, os
, architecture
and a anonymous project id to ihp-telemetry.digitallyinduced.com
. You can opt-out by setting a env var IHP_DISABLE_TELEMETRY=1
ON DELETE SET DEFAULT
: Next to ON DELETE SET NULL
you can now use SET DEFAULT
.
POINT
column in IHP. The Point type is also supported inside the param
functions.
New Migration
Generator now automatically creates the Application/Migration
directory on first use
setLayout
is not called inside the application lifecycle IHP will now continue to render a view. Previously it would crash when calling render
without a layout.
migrate
command
Next
button at the bottom of the first sections.
DEBUG=1 ./start
).
Cannot start app as postgres is not ready yet
. This error cannot happen anymore since we added database pools. Usually when this happens it's usually a false alarm.
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.
Time for the next release of IHP: v20201213 π
deleteRecordById
: Like deleteRecord
but you can pass an id instead of a full record.
startPage
now works with apps other than Web
nonEmpty
validator now works with Id record
values
InputValue Aeson.Value
instance, so form fields can be used with json fields
See the UPGRADE.md for upgrade instructions.
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 08.01.2021.
Hi there,
I have developed the backend for a web app as an HTTP API (using Servant + Warp), and I would like to use IHP to develop the web part against this HTTP API.
As far as I can see, IHP starts at the database schema level, and generates its own HTTP API from this. However, I would like to tell IHP about my HTTP API and then develop a web app against this. Is this possible currently? If so, how?
Thank you in advance :)