Integrated Haskell Platform
Learn how to configure IHP for use with Filebase.

What is Integrated Haskell Platform?

Integrated Haskell Platform, or IHP, is a full-stack framework developed to focus on rapid application deployment that utilizes robust code. IHP features a fully managed development environment, integrated development tooling, and quick response times within your production environment.
IHP has native integration for Filebase, making uploading to Filebase within your IHP code a single, seamless function. That means there’s no configuration of Filebase settings or endpoints needed, just your Filebase Access and Secret key pair.
Read below to learn how to use IHP with Filebase.

Prerequisites:

  • Download and install Integrated Haskell Platform.
  • Have Your Filebase Access and Secret Keys. Learn how to view your access keys here.
  • Create a Filebase Bucket. Learn how to create a bucket here.

1. Open your IHP Config/Config.hs file.

Insert the following line to import the IHP.FileStorage.Config package:
import IHP.FileStorage.Config

2. Next, in the same file, add the following code snippet to call the function initFilebaseStorage:

1
module Config where
2
3
import IHP.Prelude
4
import IHP.Environment
5
import IHP.FrameworkConfig
6
import IHP.FileStorage.Config
7
8
config :: ConfigBuilder
9
config = do
10
option Development
11
option (AppHostname "localhost")
12
13
initFilebaseStorage "FILEBASE_BUCKET_NAME"
Copied!
Replace FILEBASE_BUCKET_NAME with your Filebase bucket name.

3. To connect to Filebase, you will need to set environment variables that contain your Filebase Access and Secret keys.

You can do so with the commands:
export FILEBASE_KEY="FILEBASE ACCESS KEY"
export FILEBASE_SECRET="FILEBASE SECRET KEY"
You can also set these as static variables in your IHP ./start script:
1
#!/usr/bin/env bash
2
# Script to start the local dev server
3
4
# ...
5
6
export FILEBASE_KEY="FILEBASE ACCESS KEY"
7
export FILEBASE_SECRET="FILEBASE SECRET KEY"
8
9
# Finally start the dev server
10
RunDevServeras
Copied!

4. To upload your data from IHP to Filebase using this configuration, use the following syntax:

1
action UpdateCompanyAction { companyId } = do
2
company <- fetch companyId
3
company
4
|> fill @'["name"]
5
|> uploadToStorage #logoUrl
6
>>= ifValid \case
7
Left company -> render EditView { .. }
8
Right company -> do
9
company <- company |> updateRecord
10
redirectTo EditCompanyAction { .. }
Copied!
This assumes that data is in the following schema:
1
CREATE TABLE companies (
2
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
3
name TEXT NOT NULL,
4
logo_url TEXT DEFAULT NULL
5
);
Copied!
If you have any questions, please join our Discord server, or send us an email at [email protected]