Bump opium

This commit is contained in:
Paul Brinkmeier 2025-07-20 02:54:48 +02:00
parent 1a6d2cadad
commit 80f2e52327
6 changed files with 17 additions and 6 deletions

View File

@ -1,2 +1,5 @@
# yore # yore
## Inspo
- https://fz.ub.uni-freiburg.de/show/fz.cgi?pKuerzel=FZ

View File

@ -9,7 +9,7 @@ import qualified Database.PostgreSQL.Opium as Opium
import qualified Yore.DB import qualified Yore.DB
main :: IO () main :: IO ()
main = bracket (Opium.connect "host=localhost port=5432 user=yore-test dbname=yore-test") Opium.close $ \conn -> do main = bracket unsafeConnect Opium.close $ \conn -> do
result <- Yore.DB.getTables conn result <- Yore.DB.getTables conn
case result of case result of
@ -17,3 +17,5 @@ main = bracket (Opium.connect "host=localhost port=5432 user=yore-test dbname=yo
putStrLn $ "Got error: " ++ show e putStrLn $ "Got error: " ++ show e
Right rows -> Right rows ->
mapM_ print rows mapM_ print rows
where
unsafeConnect = either (error . show) id <$> Opium.connect "host=localhost port=5432 user=yore-test dbname=yore-test"

8
flake.lock generated
View File

@ -64,11 +64,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752614832, "lastModified": 1752972533,
"narHash": "sha256-rwLQ1xsYus6on4PSTwM2ti36Iwk5gr9lDKwFOZ451OI=", "narHash": "sha256-jhVfZK05aRtQ6FqLfLrhpGk8bRAkpXXXxVx4DhJgQVY=",
"ref": "main", "ref": "main",
"rev": "2fddc958b9e6b616f89570dfa44503bccd165c02", "rev": "b39da29d139763f41bffcc8c4c175e472d672f45",
"revCount": 59, "revCount": 61,
"type": "git", "type": "git",
"url": "https://git.pbrinkmeier.de/paul/opium" "url": "https://git.pbrinkmeier.de/paul/opium"
}, },

1
src/Yore/Download.hs Normal file
View File

@ -0,0 +1 @@
module Yore.Download () where

View File

@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Yore.Repl (connect, exec) where module Yore.Repl (connect, exec) where
@ -5,7 +6,10 @@ module Yore.Repl (connect, exec) where
import qualified Database.PostgreSQL.Opium as Opium import qualified Database.PostgreSQL.Opium as Opium
connect :: IO Opium.Connection connect :: IO Opium.Connection
connect = Opium.connect "host=localhost" connect =
Opium.connect "host=localhost" >>= \case
Left e -> error $ show e
Right c -> pure c
exec :: (Opium.Connection -> IO a) -> IO a exec :: (Opium.Connection -> IO a) -> IO a
exec f = f =<< connect exec f = f =<< connect

View File

@ -33,6 +33,7 @@ library
exposed-modules: exposed-modules:
Yore.DB Yore.DB
, Yore.Repl , Yore.Repl
, Yore.Download
hs-source-dirs: hs-source-dirs:
src src
build-depends: build-depends: