Compare commits

...

4 Commits

Author SHA1 Message Date
xenia 29039f1c20 Proper Main 2023-08-15 12:24:19 +02:00
xenia c359cdf84a Fix module in ICAFocus.Get 2023-08-15 12:24:10 +02:00
xenia c91c80c63f run command, cd in build and clean 2023-08-15 12:23:55 +02:00
xenia 1201987364 Add -t to xargs, add bash 2023-08-15 12:23:23 +02:00
4 changed files with 30 additions and 19 deletions

View File

@ -3,7 +3,7 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
module Get where
module ICAFocus.Get where
import qualified Network.HTTP.Client as H
import qualified Network.HTTP.Client.TLS as H

View File

@ -1,24 +1,20 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
import Control.Exception (bracket)
import Control.Monad (void, unless)
import Data.Int (Int32)
import Data.Maybe (listToMaybe)
import Control.Exception (bracket)
import Control.Monad.Except
import qualified Database.PostgreSQL.Typed as PG
import ICAFocus
import ICAFocus.Get
import DBConfig
PG.useTPGDatabase myPGDatabase
data Ingredient = Ingredient Int32
deriving (Eq)
createThing :: PG.PGConnection -> Ingredient -> IO ()
createThing pg (Ingredient product_id) =
void $ PG.pgExecute pg [PG.pgSQL|INSERT INTO ingredient (product_id) VALUES (${product_id})|]
main = bracket (PG.pgConnect myPGDatabase) PG.pgDisconnect $ \pg -> do
let ing = Ingredient 10
createThing pg ing
let lök_id = 1282116
(runExceptT $ getProduct pg lök_id) >>= \case
Right lök -> putStrLn $ "Lökat " ++ show lök
Left löklös -> putStrLn $ "Löklös? " ++ show löklös

View File

@ -1,10 +1,11 @@
#!/usr/bin/env bash
set -e
mkdir -p artifacts
log "Kompilerar backend..."
find backend -type f -and -name '*.hs' -print0 \
| xargs -0 ghc -o artifacts/Main \
| xargs -t0 ghc -o artifacts/Main \
-odir artifacts \
-hidir artifacts \
-tmpdir artifacts

View File

@ -50,12 +50,26 @@ setupDb() {
P="$PWD"
clean() {
cd "$(git rev-parse --show-toplevel)"
log "Rensar byggnad"
rm -rf artifacts
cd - >/dev/null
}
build() {
source "$P/buildScripts/build.sh"
cd "$(git rev-parse --show-toplevel)"
( source "buildScripts/build.sh" )
RES=$?
cd - >/dev/null
return $RES
}
run() {
build && {
cd "$(git rev-parse --show-toplevel)"
./artifacts/Main
cd - >/dev/null
}
}
if [ "$IS_OWNER" -ne 0 ] ; then
@ -68,4 +82,4 @@ log "Redo" "!"
set +e
cd - >/dev/null 2>&1
cd - >/dev/null