Skip to content

Haskell Quickstart Guide

Connect a Haskell application to SILO with the MinIO Haskell SDK.

MinIO Haskell SDK

SILO implements the S3-compatible server contract, so Haskell applications can use the upstream minio-hs package directly.

Warning

The latest tagged upstream release is 1.7.0, published in 2023, and its package metadata lists GHC 8.10.7 as the tested compiler. Validate minio-hs against your current GHC, resolver, TLS stack, and workload before adopting it. Check Hackage and upstream releases for newer compatibility information.

Install the package

Add minio-hs to the build-depends section of your Cabal package or to the dependency list in package.yaml. For an interactive inspection of the installed API:

cabal repl

Then run :browse Network.Minio in GHCi.

Configure the connection

Version 1.7.0 provides fromMinioEnv, which reads the following credential variables:

export S3_ENDPOINT=http://127.0.0.1:9000
export MINIO_ACCESS_KEY=silo-admin
export MINIO_SECRET_KEY=replace-with-a-strong-secret

S3_ENDPOINT is a complete URL, including the http:// or https:// scheme. Keep credentials outside source control.

Create a bucket and upload an object

Save the following as Main.hs:

{-# LANGUAGE OverloadedStrings #-}

import Control.Monad (unless)
import Data.String (fromString)
import Network.Minio
import System.Environment (getEnv)

main :: IO ()
main = do
  endpoint <- getEnv "S3_ENDPOINT"
  connection <-
    setCredsFrom [fromMinioEnv] (fromString endpoint :: ConnectInfo)

  result <- runMinio connection $ do
    let bucket = "haskell-quickstart"
        object = "hello.txt"

    exists <- bucketExists bucket
    unless exists $ makeBucket bucket Nothing
    fPutObject bucket object "hello.txt" defaultPutObjectOptions

  case result of
    Left err -> putStrLn $ "Upload failed: " ++ show err
    Right () -> putStrLn "Uploaded hello.txt"

Create hello.txt, then run the program with the build tool and resolver selected for your project. The repository’s examples directory and API reference cover streaming, presigned URLs, encryption, notifications, object locking, and other operations.

Production checklist

  • Use TLS and verify the server certificate; do not disable certificate validation.
  • Load credentials from a secret manager or protected environment.
  • Grant the application only the bucket and object permissions it needs.
  • Pin and test the GHC, resolver, SDK, TLS, and HTTP dependency versions together.
  • Define timeouts and handle MinioErr, retries, resource cleanup, and incomplete multipart uploads explicitly.

See Identity and Access Management for server-side policy configuration.