Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a Rel8 PostgreSQL adapter. #240

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ targets = build configure check test generate-fixtures docs clean realclean deps

$(targets):
$(MAKE) -C primer $@
$(MAKE) -C primer-rel8 $@
$(MAKE) -C primer-selda $@
$(MAKE) -C primer-service $@

Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ index-state: 2021-11-04T00:00:00Z

packages:
primer
primer-rel8
primer-selda
primer-service

Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
# We want -Werror for Nix builds (primarily for CI).
packages = {
primer.ghcOptions = [ "-Werror" ];
primer-rel8.ghcOptions = [ "-Werror" ];
primer-selda.ghcOptions = [ "-Werror" ];
primer-service.ghcOptions = [ "-Werror" ];
};
Expand All @@ -97,9 +98,10 @@
doHoogle = true;
}
{
# mtl-compat doesn't generate HIE files.
# These packages don't generate HIE files. See:
# https://github.com/input-output-hk/haskell.nix/issues/1242
packages.mtl-compat.writeHieFiles = false;
packages.bytestring-builder.writeHieFiles = false;
}
{
#TODO This shouldn't be necessary - see the commented-out `build-tool-depends` in primer.cabal.
Expand Down
3 changes: 3 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cradle:
- path: ./primer/test
component: "primer-test"

- path: ./primer-rel8/src
component: "lib:primer-rel8"

- path: ./primer-selda/src
component: "lib:primer-selda"

Expand Down
661 changes: 661 additions & 0 deletions primer-rel8/COPYING

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions primer-rel8/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# NOTE:
#
# Most commands assume you're running this from the top-level `nix
# develop` shell.

build:
cabal build

configure:
cabal configure

check: test

test:
cabal test

docs:
cabal haddock

clean:
cabal clean

realclean:

deps:

.PHONY: build configure test docs clean realclean deps
52 changes: 52 additions & 0 deletions primer-rel8/primer-rel8.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cabal-version: 2.4
name: primer-rel8
version: 0.7.0.0
license: AGPL-3.0-or-later
license-file: COPYING
copyright: (c) 2021 Hackworth Ltd
maintainer: [email protected]
author: Hackworth Ltd <[email protected]>
stability: experimental
synopsis: Rel8 bindings for the Primer database
category: Database

library
exposed-modules:
Primer.Database.Rel8
Primer.Database.Rel8.OrphanInstances
Primer.Database.Rel8.Rel8Db
Primer.Database.Rel8.Schema

hs-source-dirs: src
default-language: Haskell2010
default-extensions:
NoImplicitPrelude
DataKinds
DeriveDataTypeable
DeriveGeneric
DerivingStrategies
DerivingVia
FlexibleContexts
FlexibleInstances
GeneralizedNewtypeDeriving
LambdaCase
MultiParamTypeClasses
OverloadedStrings
ScopedTypeVariables

ghc-options:
-Wall -Wincomplete-uni-patterns -Wincomplete-record-updates
-Wcompat -Widentities -Wredundant-constraints -fhide-source-paths

build-depends:
, aeson >=1.5.2.0 && <=2.1
, base >=4.12 && <=4.17
, bytestring >=0.10.8.2 && <=0.12
, containers >=0.6.0.1 && <=0.7
, exceptions ^>=0.10.4
, hasql ^>=1.4.5.3
, mtl ^>=2.2.2
, primer ^>=0.7
, rel8 ^>=1.1
, text >=1.2.3.2 && <=1.3
, uuid ^>=1.3
7 changes: 7 additions & 0 deletions primer-rel8/src/Primer/Database/Rel8.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Primer.Database.Rel8 (
module Schema,
module Rel8Db,
) where

import Primer.Database.Rel8.Rel8Db as Rel8Db
import Primer.Database.Rel8.Schema as Schema
21 changes: 21 additions & 0 deletions primer-rel8/src/Primer/Database/Rel8/OrphanInstances.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Primer.Database.Rel8.OrphanInstances (
-- * Orphan instances
-- $orphanInstances
) where

import Primer.App (App)
import Rel8 (
DBType,
JSONEncoded (..),
)

-- $orphanInstances
--
-- In order to keep the Primer core library free of a "Rel8"
-- dependency, we need to define a few orphan instances.

deriving via (JSONEncoded App) instance (DBType App)
Loading