📰 Yesod(haskell) and ClojureScript Setup

Posted on March 11, 2024 by Myoungjin Jeon
Tags: haskell

Install yesod

Install ghcup

Install yesod via stack

> stack new yesod-test yesodweb/postgres
> # change lts version to my needs
> # add more packages
> stack install yesod-bin

Basic Setup 1

✎ package.yaml FIXME

stack.yaml

duplicate executable and change the name

Install & setup postgresql

  1. please have a look at settings.yml
database:
  user:     "_env:YESOD_PGUSER:whatsyourfavcoffee"
  password: "_env:YESOD_PGPASS:whatsyourfavcoffee"
  host:     "_env:YESOD_PGHOST:localhost"
  port:     "_env:YESOD_PGPORT:5432"
  # See config/test-settings.yml for an override during tests
  database: "_env:YESOD_PGDATABASE:whatsyourfavcoffee"
  poolsize: "_env:YESOD_PGPOOLSIZE:10"

please note or change that user, password and database

  1. add user with password
  2. create a database
sudo -u postgres psql # execute psql with postgres user
                      # this is demostrated on Arch Linux <2024-03-11 Mon>
[sudo] password for myoungjin:
psql (16.1)
Type "help" for help.

postgres=#
CREATE USER whatsyourfavcoffee WITH PASSWORD 'whatsyourfavcoffee';
CREATE DATABASE whatsyourfavcoffee;
postgres=# CREATE USER whatsyourfavcoffee WITH PASSWORD 'whatsyourfavcoffee';
  CREATE DATABASE whatsyourfavcoffee;
# if you see the two lines below, it is done successfully.
CREATE ROLE
CREATE DATABASE
  1. give privilege to user there is a important change since version 15.
GRANT ALL PRIVILEGES ON DATABASE whatsyourfavcoffee TO whatsyourfavcoffee;
-- Below is required for 'DB OWNDER' to make any change INSIDE of DB
ALTER DATABASE whatsyourfavcoffee OWNER TO whatsyourfavcoffee; 
postgres=#   GRANT ALL PRIVILEGES ON DATABASE whatsyourfavcoffee TO whatsyourfavcoffee;
  -- Below is required for 'DB OWNDER' to make any change INSIDE of DB
  ALTER DATABASE whatsyourfavcoffee OWNER TO whatsyourfavcoffee; 

# if you see the two lines below, it's sucessful.
GRANT
ALTER DATABASE

start yesod for the first time with yesod-scaffold-default

 stack exec yesod devel
Yesod devel server. Enter 'quit' or hit Ctrl-C to quit.
Application can be accessed at:

http://localhost:3000
https://localhost:3443
If you wish to test https capabilities, you should set the following variable:
  export APPROOT=https://localhost:3443

.. snip ..
  1. if you cannot access first page, touch Application.hs (I guess this is sort of bug, but I haven’t found the proper way to improve it)
touch src/Application.hs

Basic Setup 2