got it working again after some idle time

This commit is contained in:
nek0 2021-06-09 23:45:43 +02:00
parent e472a92fde
commit 0d7c68836b
8 changed files with 209 additions and 161 deletions

View file

@ -3,7 +3,7 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
module AppMain where module Main where
import Prelude as P import Prelude as P

View file

@ -1 +1,3 @@
index-state: 2021-02-05T00:00:00Z index-state: 2021-02-05T00:00:00Z
packages:
./

View file

@ -1,21 +1,28 @@
{ # Fetch the latest haskell.nix and import its default.nix let
haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {} # Read in the Niv sources
sources = import ./nix/sources.nix {};
# If ./nix/sources.nix file is not found run:
# niv init
# niv add input-output-hk/haskell.nix -n haskellNix
# haskell.nix provides access to the nixpkgs pins which are used by our CI, # Fetch the haskell.nix commit we have pinned with Niv
# hence you will be more likely to get cache hits when using these. haskellNix = import sources.haskellNix {};
# But you can also just use your own, e.g. '<nixpkgs>'. # If haskellNix is not found run:
, nixpkgsSrc ? haskellNix.sources.nixpkgs-2009 # niv add input-output-hk/haskell.nix -n haskellNix
# haskell.nix provides some arguments to be passed to nixpkgs, including some # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
# patches and also the haskell.nix functionality itself as an overlay. pkgs = import
, nixpkgsArgs ? haskellNix.nixpkgsArgs # haskell.nix provides access to the nixpkgs pins which are used by our CI,
# hence you will be more likely to get cache hits when using these.
# import nixpkgs with overlays # But you can also just use your own, e.g. '<nixpkgs>'.
, pkgs ? import nixpkgsSrc nixpkgsArgs haskellNix.sources.nixpkgs-2009
}: pkgs.haskell-nix.project { # These arguments passed to nixpkgs, include some patches and also
# the haskell.nix functionality itself as an overlay.
haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
# 'cleanGit' cleans a source directory based on the files known by git # 'cleanGit' cleans a source directory based on the files known by git
src = pkgs.haskell-nix.haskellLib.cleanGit { src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "mateamt"; name = "haskell-nix-project";
src = ./.; src = ./.;
}; };
# Specify the GHC version to use. # Specify the GHC version to use.

View file

@ -1,37 +1,133 @@
cabal-version: 2.4 cabal-version: 3.0
name: mateamt name: mateamt
version: 0.0.0.0 version: 0.0.0.0
synopsis: A whole new matemat synopsis: A whole new matemat
-- A longer description of the package.
-- description: -- description:
homepage: https://gitea.nek0.eu/nek0/mateamt/
-- A URL where users can report bugs.
-- bug-reports: -- bug-reports:
license: AGPL-3.0-only license: AGPL-3.0-or-later
license-file: LICENSE license-file: LICENSE
author: nek0 author: nek0
maintainer: nek0@nek0.eu maintainer: nek0@nek0.eu
-- A copyright notice.
-- copyright: -- copyright:
category: Web category: Web
extra-source-files: CHANGELOG.md extra-source-files:
README.md
CHANGELOG.md
flag develop flag develop
description: compile mateamt in developer mode. Authentication disabled, description: Compile mateamt in developer mode. Authenitcation disabled.
default: False default: False
manual: True manual: True
executable mateamt library
main-is: AppMain.hs exposed-modules:
other-modules: AppTypes Model
, AppTypes.Configuration Types
, Janitor Control
, Paths_mateamt API
-- other-extensions: Classes
build-depends: base >=4.12.0.0 && < 5 Util
, mateamt Model.Product
, text Model.Auth
, bytestring Model.User
Model.Role
Model.Journal
Model.Amount
Model.Avatar
Types.Reader
Types.Refine
Types.Product
Types.Auth
Types.User
Types.Role
Types.Purchase
Types.Journal
Types.Settings
Types.Meta
Types.Amount
Types.Avatar
Control.Product
Control.Auth
Control.User
Control.Buy
Control.Role
Control.Journal
Control.Meta
Control.Avatar
Classes.ToDatabase
Classes.FromDatabase
-- Modules included in this library but not exported.
-- other-modules:
other-extensions:
DataKinds TypeOperators FlexibleInstances MultiParamTypeClasses
RankNTypes ScopedTypeVariables FlexibleContexts OverloadedStrings
Arrows CPP LambdaCase DeriveGeneric TypeFamilies
TypeSynonymInstances
build-depends:
base ^>=4.14.1.0
, text ^>=1.2.4.1
, time ^>=1.9.3
, mtl ^>=2.2.2
, containers ^>=0.6.2.1
, bytestring ^>=0.10.12.0
, base16-bytestring
, base64-bytestring
, random-bytestring
, servant
, servant-server
, servant-rawm >= 0.3.0.0
, servant-rawm-server
, opaleye
, aeson
, profunctors
, product-profunctors
, postgresql-simple
, warp
, wai
, wai-logger
, http-types
, http-api-data
, stm
, pureMD5
, extra
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
executable mateamt
main-is: Main.hs
-- Modules included in this executable, other than Main.
other-modules:
AppTypes
AppTypes.Configuration
Janitor
Paths_mateamt
other-extensions:
DataKinds TypeOperators FlexibleInstances MultiParamTypeClasses
RankNTypes ScopedTypeVariables FlexibleContexts OverloadedStrings
Arrows CPP LambdaCase DeriveGeneric TypeFamilies
TypeSynonymInstances
build-depends:
base ^>=4.14.1.0
, mateamt
, text ^>=1.2.4.1
, time ^>=1.9.3
, mtl ^>=2.2.2
, containers ^>=0.6.2.1
, bytestring ^>=0.10.12.0
, base16-bytestring , base16-bytestring
, containers
, mtl
, opaleye , opaleye
, postgresql-simple , postgresql-simple
, postgresql-simple-migration , postgresql-simple-migration
@ -39,7 +135,6 @@ executable mateamt
, network , network
, servant , servant
, servant-server , servant-server
, time
, warp , warp
, wai , wai
, wai-logger , wai-logger
@ -49,85 +144,25 @@ executable mateamt
, case-insensitive , case-insensitive
, iproute , iproute
, clock , clock
hs-source-dirs: app hs-source-dirs: app
ghc-options: -Wall
default-language: Haskell2010
library
exposed-modules: API
, Control
, Control.Buy
, Control.Journal
, Control.User
, Control.Product
, Control.Auth
, Control.Avatar
, Control.Meta
, Control.Role
, Model
, Model.User
, Model.Product
, Model.Auth
, Model.Amount
, Model.Journal
, Model.Avatar
, Model.Role
, Types
, Types.Auth
, Types.Product
, Types.Reader
, Types.Refine
, Types.User
, Types.Purchase
, Types.Amount
, Types.Journal
, Types.Avatar
, Types.Meta
, Types.Role
, Classes
, Classes.FromDatabase
, Classes.ToDatabase
, Util
-- other-extensions:
build-depends: base >=4.12.0.0 && < 5
, servant
, servant-server
, servant-rawm >= 0.3.0.0
, servant-rawm-server
, opaleye
, aeson
, text
, time
, profunctors
, product-profunctors
, postgresql-simple
, warp
, wai
, wai-logger
, http-types
, http-api-data
, bytestring
, base16-bytestring
, base64-bytestring
, random-bytestring
, containers
, stm
, mtl
, pureMD5
, extra
hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall ghc-options: -Wall
if flag(develop)
cpp-options: -DDEVELOP
test-suite spec test-suite mateamt-test
default-language: Haskell2010
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: test hs-source-dirs: test
ghc-options: -Wall ghc-options: -Wall
build-depends: base main-is: TestMain.hs
build-depends:
base ^>=4.14.1.0
, mateamt , mateamt
, text ^>=1.2.4.1
, time ^>=1.9.3
, mtl ^>=2.2.2
, containers ^>=0.6.2.1
, bytestring ^>=0.10.12.0
, hspec , hspec
, hspec-wai , hspec-wai
, hspec-wai-json , hspec-wai-json
@ -135,11 +170,10 @@ test-suite spec
, wai , wai
, pg-transact , pg-transact
, tmp-postgres , tmp-postgres
, bytestring
, resource-pool , resource-pool
, postgresql-simple , postgresql-simple
other-modules: TestUtil build-tool-depends:
, Spec hspec-discover:hspec-discover
, AppMainSpec other-modules:
default-language: Haskell2010 TestUtil
build-tool-depends: hspec-discover:hspec-discover AppMainSpec

View file

@ -148,5 +148,7 @@ userNotify
-> [PurchaseDetail] -> [PurchaseDetail]
-> PurchaseResult -> PurchaseResult
-> MateHandler () -> MateHandler ()
userNotify (Just (auid, method)) boughtItems (PruchaseResult flag missing) = do userNotify (Just (auid, method)) boughtItems (PurchaseResult flag missing) = do
throwError $ err501
{ errBody = "userNotify: Not implemented yet"
}

View file

@ -3,20 +3,23 @@ module Types.Settings where
import qualified Data.Text as T import qualified Data.Text as T
import Classes
data Settings = Settings data Settings = Settings
{ settingsCurrency :: T.Text { settingsCurrency :: T.Text
, settingsDecimalPlaces :: Int , settingsDecimalPlaces :: Int
, settingsBlockRegistration :: Bool , settingsBlockRegistration :: Bool
} }
deriving (Show)
instance ToDatabase Settings where instance ToDatabase Settings where
data InTuple Settings = (T.Text, Int, Bool) type InTuple Settings = (T.Text, Int, Bool)
toDatabase (Settings currency places reg) = (currency, places, reg) toDatabase (Settings currency places reg) = (currency, places, reg)
instance FromDatabase Settins where instance FromDatabase Settings where
data OutTuple Settings = (T.Text, Int, Bool) type OutTuple Settings = (T.Text, Int, Bool)
fromDatabase (currency, places, reg) = Settings currency places reg fromDatabase (currency, places, reg) = Settings currency places reg