Compare commits
No commits in common. "29039f1c20cf1e61caecb0f1aa7bde74e0568320" and "da52df1e8f821de8d376d1c6bd794d93c028f8bc" have entirely different histories.
29039f1c20
...
da52df1e8f
|
@ -3,7 +3,7 @@
|
|||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module ICAFocus.Get where
|
||||
module Get where
|
||||
|
||||
import qualified Network.HTTP.Client as H
|
||||
import qualified Network.HTTP.Client.TLS as H
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
|
||||
import Control.Exception (bracket)
|
||||
import Control.Monad.Except
|
||||
import Control.Exception (bracket)
|
||||
import Control.Monad (void, unless)
|
||||
import Data.Int (Int32)
|
||||
import Data.Maybe (listToMaybe)
|
||||
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 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
|
||||
let ing = Ingredient 10
|
||||
createThing pg ing
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
mkdir -p artifacts
|
||||
|
||||
log "Kompilerar backend..."
|
||||
find backend -type f -and -name '*.hs' -print0 \
|
||||
| xargs -t0 ghc -o artifacts/Main \
|
||||
| xargs -0 ghc -o artifacts/Main \
|
||||
-odir artifacts \
|
||||
-hidir artifacts \
|
||||
-tmpdir artifacts
|
||||
|
|
|
@ -50,26 +50,12 @@ setupDb() {
|
|||
|
||||
P="$PWD"
|
||||
clean() {
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
log "Rensar byggnad"
|
||||
rm -rf artifacts
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
build() {
|
||||
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
|
||||
}
|
||||
source "$P/buildScripts/build.sh"
|
||||
}
|
||||
|
||||
if [ "$IS_OWNER" -ne 0 ] ; then
|
||||
|
@ -82,4 +68,4 @@ log "Redo" "!"
|
|||
|
||||
set +e
|
||||
|
||||
cd - >/dev/null
|
||||
cd - >/dev/null 2>&1
|
||||
|
|
Loading…
Reference in New Issue
Block a user