Skip to content

Commit

Permalink
[ADP-2565] Clean up package delta-table (#4673)
Browse files Browse the repository at this point in the history
This pull request cleans up the `delta-table` package in order to
prepare the implementation of a library for working with SQL tables.

Specifically, this pull requests

* Splits off existing code into a `delta-chain` package, to be cleaned
up later.
* Removes most modules from the `delta-table` package.

### Issue Number

ADP-2565
  • Loading branch information
HeinrichApfelmus authored Jul 15, 2024
2 parents 88d07b3 + 4c6ade6 commit d5cfc83
Show file tree
Hide file tree
Showing 15 changed files with 770 additions and 65 deletions.
6 changes: 5 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ packages:
lib/crypto-primitives/
lib/coin-selection/
lib/customer-deposit-wallet/
lib/delta-chain/
lib/delta-store/
lib/delta-table
lib/delta-table/
lib/delta-types/
lib/faucet/
lib/iohk-monitoring-extra/
Expand Down Expand Up @@ -231,6 +232,9 @@ cabal-lib-version: 3.6

test-show-details: direct

package delta-chain
tests: True

package delta-store
tests: True

Expand Down
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ unit-tests-cabal-match match:
cardano-wallet-secrets:test \
cardano-wallet-test-utils:unit \
cardano-wallet-unit:unit \
delta-chain:unit \
delta-store:unit \
delta-table:unit \
delta-types:unit \
Expand Down
22 changes: 22 additions & 0 deletions lib/delta-chain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Overview

At the time of this writing, the package contains
an early prototype of a `Table` type that represents
database tables, and an example usage can be found in `Data.Chain`.

The main modules are:

* [Data.Table](src/Data/Table.hs) — database
* Contains the `Table` dataype, which models a table as you would find it in a database.
* [Data.Chain](src/Data/Delta.hs) — (block)chain
* Contains the `Chain` datatype, which is more specific
to the problem domain of storing a linear sequence
of checkpoints. Useful in a blockchain setting.

In addition, this package contains
* [Database.Persist.Delta](src/Database/Persist/Delta.hs) — database
* Implements a `Store` in an SQLite database for the `Entity` types in the `persistent` package.
* Implements a `Store` using raw SQL commands.
* [Database.Schema](src/Database/Schema.hs) — database
* Contains the `IsRow` type class for typed database rows, very similar to the style of the [servant](https://hackage.haskell.org/package/servant) package.
* Example: `type PersonRow = Table "person" :. Col "name" Text :. Col "birth" Int :. Col "id" Primary`.
81 changes: 81 additions & 0 deletions lib/delta-chain/delta-chain.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
cabal-version: 3.6
build-type: Simple
name: delta-chain
version: 0.2024.5.5
synopsis: Example for storing a chain in a database, using delta types.
description: Please see README.md
homepage: https://github.com/cardano-foundation/cardano-wallet
license: Apache-2.0
author: Cardano Foundation (High Assurance Lab)
maintainer: hal@cardanofoundation.org
copyright: 2023-2024 Cardano Foundation
category: Database

extra-source-files:
README.md

common language
default-language:
Haskell2010
default-extensions:
NoImplicitPrelude
OverloadedStrings

common opts-lib
ghc-options:
-Wall -Wcompat
-Wredundant-constraints
-Wincomplete-uni-patterns -Wincomplete-record-updates

if flag(release)
ghc-options: -O2 -Werror

common opts-exe
import: opts-lib
ghc-options: -threaded -rtsopts

flag release
description: Enable optimization and `-Werror`
default: False
manual: True

library
import: language, opts-lib
hs-source-dirs: src
build-depends:
base
, conduit
, containers
, delta-store
, delta-types
, exceptions
, generic-lens
, io-classes
, monad-logger
, persistent
, persistent-sqlite
, say
, semigroupoids
, stm
, text
, transformers
hs-source-dirs:
src
exposed-modules:
Data.Chain
Data.Table
Database.Persist.Delta
Database.Schema
other-modules:
Demo.Database

test-suite unit
import: language, opts-exe
type: exitcode-stdio-1.0
hs-source-dirs: test/unit
main-is: Main.hs
build-tool-depends:
hspec-discover:hspec-discover
build-depends:
base
, hspec
File renamed without changes.
Loading

0 comments on commit d5cfc83

Please sign in to comment.