Logs: liberachat/#haskell
| 2021-07-12 23:48:45 | <lambdabot> | Distribution.Compat.Prelude.Internal class IsString a |
| 2021-07-12 23:48:52 | <geekosaur> | (you're defeating its intended type safety) |
| 2021-07-12 23:49:01 | <Axman6> | @hoogle fromString |
| 2021-07-12 23:49:01 | <lambdabot> | Data.String fromString :: IsString a => String -> a |
| 2021-07-12 23:49:01 | <lambdabot> | GHC.Exts fromString :: IsString a => String -> a |
| 2021-07-12 23:49:01 | <lambdabot> | Data.Text.Internal.Builder fromString :: String -> Builder |
| 2021-07-12 23:49:42 | <AWizzArd> | Raugh: the `Query` constructor takes a ByteString. You could try let q = Query (BS.pack "SELECT from file") |
| 2021-07-12 23:50:15 | <AWizzArd> | Raugh: possibly you can read it directly as ByteString from the file. |
| 2021-07-12 23:50:46 | <AWizzArd> | I am doing something similar. I read strings as BS from Postgres actually. I have queries stored in there. I retrieve them and then run them. |
| 2021-07-12 23:52:39 | <Axman6> | Isn't that what stored procedures are for? |
| 2021-07-12 23:52:48 | <Raugh> | interesting, ok, trying each method. Its not escaping a substituted table name correct for me either and I'm realizing it might not be set up to run multiple statements at once out of the box so I think I have a bit of digging to do |
| 2021-07-12 23:53:05 | <hololeap> | how would I make a --help option with optparse-applicative? |
| 2021-07-12 23:53:13 | <Axman6> | no, it almost certainly isn't |
| 2021-07-12 23:53:14 | <AWizzArd> | Axman6: sure, but in my case the queries are editable by certain admin users. |
| 2021-07-12 23:53:21 | <Axman6> | quick hack would be to split on ; |
| 2021-07-12 23:53:45 | → | argento joins (~argent0@168-227-97-29.ptr.westnet.com.ar) |
| 2021-07-12 23:54:38 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:6d00:2ab2:6519:235b) |
| 2021-07-12 23:54:50 | × | argento quits (~argent0@168-227-97-29.ptr.westnet.com.ar) (Client Quit) |
| 2021-07-12 23:55:21 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-07-12 23:56:56 | × | lavaman quits (~lavaman@98.38.249.169) (Remote host closed the connection) |
| 2021-07-12 23:57:08 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-07-12 23:59:11 | <hololeap> | this seems really convoluted for such a common use case |
| 2021-07-13 00:00:11 | → | myShoggoth joins (~myShoggot@97-120-70-214.ptld.qwest.net) |
| 2021-07-13 00:01:17 | <Axman6> | hololeap: https://github.com/pcapriotti/optparse-applicative |
| 2021-07-13 00:02:39 | <hololeap> | Axman6: ha, I should have looked there first ... :) |
| 2021-07-13 00:03:12 | → | vicfred joins (~vicfred@user/vicfred) |
| 2021-07-13 00:05:09 | <AWizzArd> | Looking for: (Traversable t) => t a -> Maybe a |
| 2021-07-13 00:05:51 | <Axman6> | (^? traverse) :P |
| 2021-07-13 00:05:59 | <Axman6> | :t (^? traverse) |
| 2021-07-13 00:06:00 | <lambdabot> | Traversable t => t a -> Maybe a |
| 2021-07-13 00:06:28 | <glguy> | :t foldr (\x _ -> Just x) Nothing |
| 2021-07-13 00:06:29 | <lambdabot> | Foldable t => t a -> Maybe a |
| 2021-07-13 00:06:36 | <Raugh> | hmm, neither fromString nor BS.pack are working for me |
| 2021-07-13 00:06:41 | <Raugh> | constructor not in scope |
| 2021-07-13 00:07:15 | <Raugh> | AWizzArd: are you using that exact syntax? for me its a type error |
| 2021-07-13 00:08:31 | <geekosaur> | looks to me like the Query data constructor might not be exported |
| 2021-07-13 00:08:42 | <AWizzArd> | What is your type error? In my code I have literally: (Query qry) where `qry` is coming from my DB from an earlier query. |
| 2021-07-13 00:09:22 | <AWizzArd> | geekosaur: I am doing import Database.PostgreSQL.Simple.Types ( Query (..) ) |
| 2021-07-13 00:09:25 | <geekosaur> | which was a worry given the docs said it was a wrapped ByteString with a restricted API for type safety |
| 2021-07-13 00:09:56 | <geekosaur> | AWizzArd, that might well succeed importing nothing if the data constructor isn't exported |
| 2021-07-13 00:10:17 | <AWizzArd> | geekosaur: I can at least tell that my code runs/works. |
| 2021-07-13 00:10:31 | <geekosaur> | what version of postgresql-simple? |
| 2021-07-13 00:10:40 | <Axman6> | it's ecported in the latest release |
| 2021-07-13 00:10:45 | <Axman6> | exported* |
| 2021-07-13 00:11:12 | <Raugh> | how do i tell which version got pulled in by stack? |
| 2021-07-13 00:11:23 | <AWizzArd> | geekosaur: https://hackage.haskell.org/package/postgresql-simple-0.6.4/docs/src/Database.PostgreSQL.Simple.Types.html |
| 2021-07-13 00:11:33 | <Raugh> | Yeah I'm impoerting Query (..) |
| 2021-07-13 00:11:33 | <AWizzArd> | In there I see an export. |
| 2021-07-13 00:11:48 | <AWizzArd> | Raugh: can you please paste the type error that you see? |
| 2021-07-13 00:11:55 | × | Tuplanolla quits (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi) (Quit: Leaving.) |
| 2021-07-13 00:12:13 | <Raugh> | 0.6.4 |
| 2021-07-13 00:12:14 | <geekosaur> | yeh, I just checked that myself |
| 2021-07-13 00:12:22 | <geekosaur> | so it's exported |
| 2021-07-13 00:12:35 | <AWizzArd> | newtype Query = Query { fromQuery :: ByteString } deriving (Eq, Ord, Typeable)} deriving (Eq, Ord, Typeable) |
| 2021-07-13 00:12:41 | × | yaroot quits (~yaroot@6.3.30.125.dy.iij4u.or.jp) (Quit: The Lounge - https://thelounge.chat) |
| 2021-07-13 00:13:01 | <AWizzArd> | Raugh: if you import Query (..) and pass in a ByteString then it will work. |
| 2021-07-13 00:13:06 | × | favonia quits (~favonia@user/favonia) (Ping timeout: 240 seconds) |
| 2021-07-13 00:13:17 | <Raugh> | ok its imported now i'm on to bytesting errors i should be able to figure these out |
| 2021-07-13 00:13:30 | → | yaroot joins (~yaroot@6.3.30.125.dy.iij4u.or.jp) |
| 2021-07-13 00:13:54 | <Raugh> | BS.pack is expecting a Word8 not [Char] going to the docs |
| 2021-07-13 00:13:59 | <AWizzArd> | Raugh: from what module do you try to import ByteString? The PG lib is doing it like this: import Data.ByteString (ByteString) |
| 2021-07-13 00:14:11 | <AWizzArd> | I keep forgetting if this is strict or lazy. |
| 2021-07-13 00:14:28 | <Raugh> | import qualified Data.ByteString as BS (pack) |
| 2021-07-13 00:14:30 | <geekosaur> | Raugh, you should probably use what I pasted originally, which deals with UTF8 |
| 2021-07-13 00:14:58 | <geekosaur> | there's an ugly hack Data.ByteString.Char8 but that will fail if there's any Unicode involved |
| 2021-07-13 00:15:22 | <geekosaur> | it pack will appear to work but silently produce garbage |
| 2021-07-13 00:15:25 | <geekosaur> | *its |
| 2021-07-13 00:15:32 | <AWizzArd> | Raugh: how do you read from your file? Are you using something like https://hackage.haskell.org/package/bytestring-0.11.1.0/docs/Data-ByteString.html#v:readFile |
| 2021-07-13 00:15:56 | × | mikolaj__ quits (~mikon@duch.mimuw.edu.pl) (Ping timeout: 265 seconds) |
| 2021-07-13 00:16:06 | <Raugh> | geekosaur: I couldn't parse what you posted, should I be using Data.String fromString? |
| 2021-07-13 00:16:48 | <Raugh> | I'm using a derpy yaml config of all things, maybe its time to go back to the books on this one. |
| 2021-07-13 00:17:05 | <geekosaur> | https://hackage.haskell.org/package/postgresql-simple-0.6.4/docs/src/Database.PostgreSQL.Simple.Types.html#line-90 which uses stringUtf8 and fromString |
| 2021-07-13 00:17:34 | → | mikolaj joins (~mikon@duch.mimuw.edu.pl) |
| 2021-07-13 00:17:40 | <geekosaur> | alternately read the ByteString as a ByteString and just wrap it in Query |
| 2021-07-13 00:18:03 | × | chomwitt quits (~Pitsikoko@2a02:587:dc04:e00:12c3:7bff:fe6d:d374) (Remote host closed the connection) |
| 2021-07-13 00:18:44 | <AWizzArd> | Raugh: yeah, what geekosaur just wrote sounds good. Can you possibly use a `readFile` function that will actually give you directly a BS? |
| 2021-07-13 00:19:20 | × | Danishman quits (~Allan@2-104-144-110-cable.dk.customer.tdc.net) (Quit: Leaving) |
| 2021-07-13 00:19:54 | <AWizzArd> | glguy: ah, interesting foldr! |
| 2021-07-13 00:20:32 | → | mikail_ joins (~mikail@2a02:c7f:bd83:fd00:55cf:122f:957a:f66f) |
| 2021-07-13 00:20:36 | × | Vajb quits (~Vajb@hag-jnsbng11-58c3a1-224.dhcp.inet.fi) (Read error: Connection reset by peer) |
| 2021-07-13 00:20:49 | → | Vajb joins (~Vajb@2001:999:62:1d53:26b1:6c9b:c1ed:9c01) |
| 2021-07-13 00:22:08 | <Raugh> | geekosaur: oh interesting, i'll try it that uses some parts of postgresql.simple as well |
| 2021-07-13 00:22:17 | × | trufas quits (~trufas@177.240.218.218) (Ping timeout: 252 seconds) |
| 2021-07-13 00:22:50 | → | trufas joins (~trufas@177.240.218.218) |
| 2021-07-13 00:25:08 | × | mikail_ quits (~mikail@2a02:c7f:bd83:fd00:55cf:122f:957a:f66f) (Ping timeout: 256 seconds) |
| 2021-07-13 00:27:23 | → | warnz joins (~warnz@2600:1700:77c0:5610:acd9:fdbc:f96e:2452) |
| 2021-07-13 00:28:07 | × | Deide quits (~Deide@user/deide) (Quit: Seeee yaaaa) |
| 2021-07-13 00:30:06 | → | dajoer joins (~david@user/gvx) |
| 2021-07-13 00:31:56 | × | warnz quits (~warnz@2600:1700:77c0:5610:acd9:fdbc:f96e:2452) (Ping timeout: 256 seconds) |
| 2021-07-13 00:31:57 | × | Vajb quits (~Vajb@2001:999:62:1d53:26b1:6c9b:c1ed:9c01) (Read error: Connection reset by peer) |
| 2021-07-13 00:32:50 | → | Vajb joins (~Vajb@hag-jnsbng11-58c3a1-224.dhcp.inet.fi) |
| 2021-07-13 00:34:25 | <Raugh> | lol, ok copied the same composition of funcions in as a helper but now for some reason its injecting table names in my sql wrong its adding quotes around them I must be using the wrong type. I'm using Only String as the table name |
| 2021-07-13 00:35:31 | <c_wraith> | most parameterized query libraries don't let you parameterize the name of the table |
| 2021-07-13 00:38:04 | tabemann_ | is now known as tabemann |
| 2021-07-13 00:38:17 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-07-13 00:39:10 | → | mikail_ joins (~mikail@2a02:c7f:bd83:fd00:55cf:122f:957a:f66f) |
| 2021-07-13 00:39:59 | × | chris-the-slurpa quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2021-07-13 00:41:00 | <Raugh> | ok, i think i'm starting to be able to walk here. Theres an Identifier in types i can use to tell it to treat it as a table name |
| 2021-07-13 00:41:34 | × | myShoggoth quits (~myShoggot@97-120-70-214.ptld.qwest.net) (Ping timeout: 256 seconds) |
| 2021-07-13 00:42:40 | → | retro_ joins (~retro@90.218.175.34) |
All times are in UTC.