Questions tagged [hasql]

A minimalistic general high level API for Postgresql clients in Haskell

Hasql is a highly efficient PostgreSQL driver and a mapping API. It targets both the users, who need a low level of abstraction, and the users, who face the typical tasks of DB-powered applications, providing them with higher-level APIs.

For details and other links please visit the GitHub page.

9 questions
3
votes
1 answer

Hasql's session and IO

I wrote a function app :: Request -> H.Session H.Postgres IO Response which accepts web requests and builds responses (consulting the database as needed). To actually send out the responses I made a wrapper runApp :: H.Postgres -> H.SessionSettings…
Nikita Volkov
  • 42,792
  • 11
  • 94
  • 169
2
votes
1 answer

How do you get Haskell to check SQL at compile time?

I know it can be done, but I'm having trouble getting it working. I'm still finding my feet with Haskell. I tried using postgresql-typed, but it wouldn't compile. They don't enable the QuasiQuotes extension, so I don't understand how their code…
mikevdg
  • 370
  • 1
  • 7
2
votes
1 answer

Hasql: encode a sum-type

How to encode the following sum-type using Hasql? I tried to create an encoder sumValue :: Value SumValue, but I can't pattern match. E.g. I would like to encode SumBool with Hasql.Encoders.bool and SumChar with Hasql.Encoders.char. data SumValue …
2
votes
1 answer

Encoding a Parameter List for a Hasql query

I'm trying to get Hasql to encode a list for a "select ... where in" query. It typechecks if I use contramany from contravariant-extras, but I get a syntax error at runtime. import qualified Database.Encoders as E import…
Mikkel
  • 762
  • 5
  • 17
1
vote
1 answer

Consuming Hasql statement outputs using something like a parser

I have an application which models a data domain using some deeply nested record structures. A contrived but analogous example would be something like: Book - Genre - Author - Hometown - Country I've found that when writing queries…
GTF
  • 8,031
  • 5
  • 36
  • 59
1
vote
1 answer

Hasql: Error from variable substitution in 'SET' statement

I'm trying to write a parameterized statement with Hasql to set a variable in PostgreSQL. import qualified Hasql.Encoders as E import qualified Hasql.Decoders as D setOrganization :: Query Int64 () setOrganization = statement sql (E.value E.int8)…
Mikkel
  • 762
  • 5
  • 17
1
vote
1 answer

Hasql Session's return value variable getting stuck with specific type?

I am attempting to connect to Postgres once, outside of my Spock application, but I can't seem to use a Hasql session handle with multiple return types. My main application is fairly straightforward, but fails to compile. mainApp :: IO…
cschneid
  • 460
  • 4
  • 10
0
votes
1 answer

No instance for (Data.Vector.Generic.Base.Vector ...) when using Hasql.TH

I have a query I'm running in Hasql using Hasql.TH, and I'm encountering an error I've never seen before (see below). I'm seen this SO question/answer which references the version of vector, but (a) I'm using stack so these things should be resolved…
GTF
  • 8,031
  • 5
  • 36
  • 59
0
votes
0 answers

How can i access :: Hasql.Pool.Pool inside :: BasicAuthCheck User?

I usually pass :: Hasql.Pool.Pool to serve function as an argument through run as an argument from main :: IO () But ever since I started planning to use :: BasicAuthCheck User for authentication, I started needing :: Hasql.Pool.Pool inside ::…