Fairly new to Purescript with some light Haskell experience. I’m trying to access a SQLite database via the SQLite3 package using code that is almost verbatim from the example the package provides:
while trying to match type Aff Unit
with type Effect t0
while checking that expression closeDB conn
has type Effect t0
in value declaration getMerchants
where t0 is an unknown type
I understand that the closeDB line returns an Aff, but I was under the impression that I’m feeding that Aff into launchAff, which takes that Aff and returns an Effect.
Any help would be greatly appreciated as I’ve spent the last four hours just trying to figure out how to open and close a SQLite connection.
Whose log are you using? Effect.Console.log and Effect.Class.Console.log are different, I think the latter may work for you? (Possibly, I’m unsure though as I haven’t used the latter)
Looking at the type signatures of each, it does seem like I should’ve been using Effect.Class.Console.log. I’ll try it out when I’m back at work tomorrow and see if it solves the issue. Thanks for the response!
So changing the log to Effect.Class.Console has shifted the error to the log line (second from the bottom) and it now reads:
Could not match type
Aff
with type
Function (Array Foreign)
while trying to match type t1 t2
with type Array Foreign -> t0
while checking that expression (discard ((apply log) ((…) (…)))) ($__unused ->
closeDB conn
)
has type Array Foreign -> t0
in value declaration getMerchants
where t0 is an unknown type
t2 is an unknown type
t1 is an unknown type
That has moved the error to just the queryDB function call. It now reads:
Could not match type
Foreign
with type
t1 t2
while trying to match type Aff Foreign
with type t0 (t1 t2)
while checking that expression ((queryDB conn) “SELECT 1 from merchants”) []
has type t0 (t1 t2)
in value declaration getMerchants
where t0 is an unknown type
t1 is an unknown type
t2 is an unknown type
I think the example in the documentation is possibly outdated, as queryDB returns Aff Foreign, so your function on the LHS of <$> should be of type Foreign -> b, yet the documentation uses rows as if it was an array-like