• Stars
    star
    478
  • Rank 91,950 (Top 2 %)
  • Language
    Haskell
  • License
    MIT License
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A type-safe, high-level SQL library for Haskell

Selda

Join the chat at https://gitter.im/selda-hs/Lobby Hackage IRC channel MIT License Haskell CI Hackage Dependencies

What is Selda?

Selda is a Haskell library for interacting with SQL-based relational databases. It was inspired by LINQ and Opaleye.

Features

  • Monadic interface.
  • Portable: backends for SQLite and PostgreSQL.
  • Generic: easy integration with your existing Haskell types.
  • Creating, dropping and querying tables using type-safe database schemas.
  • Typed query language with products, filtering, joins and aggregation.
  • Inserting, updating and deleting rows from tables.
  • Conditional insert/update.
  • Transactions, uniqueness constraints and foreign keys.
  • Type-safe, backend-specific functionality, such as JSON lookups.
  • Seamless prepared statements.
  • Lightweight and modular: few dependencies, and non-essential features are optional or split into add-on packages.

Getting started

Install the selda package from Hackage, as well as at least one of the backends:

$ cabal update
$ cabal install selda selda-sqlite selda-postgresql

Then, read the tutorial. The API documentation will probably also come in handy.

Requirements

Selda requires GHC 8.0+, as well as SQLite 3.7.11+ or PostgreSQL 9.4+. To build the SQLite backend, you need a C compiler installed. To build the PostgreSQL backend, you need the libpq development libraries installed (libpq-dev on Debian-based Linux distributions).

Hacking

Contributing

All forms of contributions are welcome!

If you have a bug to report, please try to include as much information as possible, preferably including:

  • A brief description (one or two sentences) of the bug.
  • The version of Selda+backend where the bug was found.
  • A step-by-step guide to reproduce the bug.
  • The expected result from following these steps.
  • What actually happens when following the steps.
  • Which component contains the bug (selda, selda-sqlite or selda-postgresql), if you're reasonably sure about where the bug is.

Bonus points for a small code example that illustrates the problem.

If you want to contribute code, please consult the following checklist before sending a pull request:

  • Does the code build with a recent version of GHC?
  • Do all the tests pass?
  • Have you added any tests covering your code?

If you want to contribute code but don't really know where to begin, issues tagged good first issue are a good start.

Setting up the build environment

From the repository root:

  • Install libpq-dev from your package manager. This is required to build the PostgreSQL backend.
  • Make sure you're running a cabal version that supports v2-style commands.
  • Familiarise yourself with the various targets in the makefile. The dependencies between Selda, the backends and the tests are slightly complex, so straight-up cabal is too quirky for day to day hacking.

PostgreSQL backend testing with Docker

To test the PostgreSQL backend, use the provided pgtest-compose.yml docker-compose file:

sudo docker-compose -f pgtest-compose.yml up -d
make pgtest
sudo docker-compose -f pgtest-compose.yml down

TODOs

Features that would be nice to have but are not yet implemented.

  • Monadic if/else
  • Streaming
  • MySQL/MariaDB backend
  • MSSQL backend

More Repositories

1

haste-compiler

A GHC-based Haskell to JavaScript compiler
Haskell
1,446
star
2

4koma

A TOML 1.0 parser library for Kotlin
Kotlin
73
star
3

konbini

Parser library for Kotlin
Kotlin
44
star
4

bt-reload-headphones

Workaround for wonky Sony (possibly other) BT headphones
Shell
28
star
5

lambdascript

Ugly prototype language for strongly typed, lazy, purely functional client side web scripting
Haskell
25
star
6

ghc-simple

Simplified interface to the GHC API
Haskell
24
star
7

shellmate

Write type-safe shell scripts in Haskell
Haskell
14
star
8

fursuit

FUnctional Reactivity with Signals Using a sIngle Thread of control
Haskell
11
star
9

ghc-sd

Build a GHC which produces shared libraries without runtime Haskell dependencies
Dockerfile
10
star
10

haste-app

Development version of Haste.App
Haskell
9
star
11

data-embed

Bundle data files inside executables, for easy access and single file distribution.
Haskell
8
star
12

squeekboard-sway

Sway-friendly mod of the original Squeekboard keyboard
Rust
7
star
13

haste-deck

Create presentation slides and simple web pages using an intuitive DSL
Haskell
7
star
14

zalgo

A somewhat flexible Zalgo̐ te̳͜x̥̖̉̓͞t̍̌̔ ̀̃t̴̢̞̜͓̝r̶̬̆̂̒͟á̧̡͎͔̯̰̕n̹̾̓ͬͦ̍͘ṡ̢͓͉ͮ͆l̠̖̹̗̳̖̽̌ͤ͞a͚̭͙̹̲ͭͩt͈͐o̢̭͇͍̟͐ͬ̾ͪ͜r͇.̸̅ͭ̐̀̊ͨ͛
Haskell
7
star
15

ctagsymbols

CTags workspace symbol provider extension for Visual Studio Code
JavaScript
6
star
16

haste-standalone

Create zero configuration standalone Haste.App web apps
Haskell
6
star
17

aoc21

Advent of Code 2021 in Haskell
Haskell
6
star
18

wanchan

NyaaTorrents watcher, scraper, explorer and downloader - now with a fancy web interface
Haskell
6
star
19

dpress

Generating random sequences using n-grams in Haskell
Haskell
4
star
20

threefish

Haskell implementation of the Threefish block cipher and the Skein hash function built on it.
Haskell
4
star
21

ask

User input convenience functions for console programs
Haskell
4
star
22

mcctl

Robust and simple Minecraft daemon manager
Haskell
3
star
23

threefish.js

Javascript implementation of the Threefish block cipher and Skein hash function
3
star
24

advent-2018

Haskell solutions to Advent of Code 2018
Haskell
3
star
25

haskell-mpv

Thread-safe Haskell wrapper around libmpv
Haskell
3
star
26

domplate

Haskell
2
star
27

picube

Haste powered info screens, photo frames, etc.
Haskell
2
star
28

mat

What's for lunch today around Grönsakstorget, Gothenburg?
Python
2
star
29

thpp

Template Haskell as a preprocessor
Haskell
2
star
30

pix

Haskell
2
star
31

rfinder

Ugly hack for locating resource clusters in Minecraft maps.
Haskell
2
star
32

tini

Tiny INI file and generic configuration library
Haskell
2
star
33

lambnyaa

Haskell
1
star
34

ffi-paper

TeX
1
star
35

erlbot

IRC bot written in Erlang
Erlang
1
star
36

himitsu

Haskell
1
star
37

typhpist

A bunch of classes to allow for type safe generation of valid XHTML documents with PHP.
PHP
1
star
38

datastrukt-travelgui

Haskell
1
star
39

kagamin

Haskell
1
star
40

aplite-benchmarks

Benchmarks comparing Aplite with non-Aplite Haskell and hand-rolled JavaScript
Haskell
1
star
41

ccwf

Chalmers Course Website Framework
Haskell
1
star
42

phdtools

Timekeeping tool for multiple projects
Haskell
1
star
43

servermanager

Haskell
1
star
44

grape

Generic Reification of ADTs and Patterns in EDSLs
Haskell
1
star
45

twofish

A pure-haskell implementation of the Twofish symmetric block encryption cipher
Haskell
1
star
46

hangouts-logbaker

Working with Hangouts logs from Google Takeaway in Haskell and SQLite
Haskell
1
star