Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,397 events total
2021-08-23 21:52:06 <monochrom> Value-level programming questions.
2021-08-23 21:52:32 <monochrom> "How do I traverse a list at the value level only?"
2021-08-23 21:52:56 <dminuoso> https://aphyr.com/posts/342-typing-the-technical-interview
2021-08-23 21:53:04 <dminuoso> monochrom: You knew this was coming, didn't you?
2021-08-23 21:53:05 <hseg> oh that's a classic
2021-08-23 21:54:52 <monochrom> I enjoyed that one as a joke. Didn't think of it as prophecy though. Well, I guess I didn't have foresight.
2021-08-23 21:55:48 <monochrom> But yeah some of that could be improved by type families today.
2021-08-23 21:56:41 <monochrom> On second thought, I didn't study type-level programming, I don't actually know whether type families would help that one.
2021-08-23 21:58:23 <monochrom> And then you can also criticize me for turning down term-level questions when they actually come up, such as yesterday, with "I can't believe that your prof's course material didn't show examples".
2021-08-23 22:00:18 <dminuoso> Or "I can't believe that your prof's course material didn't start off with type families"
2021-08-23 22:00:26 <dminuoso> That's where your job is headed.
2021-08-23 22:00:46 <dminuoso> Soon we will abolish code generation in GHC.
2021-08-23 22:01:29 <batch12> dminuoso: This does the job:
2021-08-23 22:01:29 <batch12> type family IsShow (a :: [*]) :: Constraint where
2021-08-23 22:01:29 <batch12> IsShow '[] = ()
2021-08-23 22:01:29 <batch12> IsShow (h:t) = (Show h, IsShow t)
2021-08-23 22:01:59 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f) (Remote host closed the connection)
2021-08-23 22:02:28 <dminuoso> % type family IsShow (a :: [*]) :: Constraint where IsShow '[] = (); IsShow (h:t) = (Show h, IsShow t)
2021-08-23 22:02:28 <yahb> dminuoso:
2021-08-23 22:03:01 <dminuoso> And how do you intend to use this?
2021-08-23 22:04:58 <batch12> I'm maintaining a stack of operations that are attached to some values
2021-08-23 22:05:43 <batch12> (the actual class is not show..)
2021-08-23 22:05:57 <batch12> Thanks for the help!
2021-08-23 22:08:18 <fresheyeball> ok I got another quandry
2021-08-23 22:08:25 <fresheyeball> postgresql simple
2021-08-23 22:08:35 <fresheyeball> Incompatible {errSQLType = "record", errSQLTableOid = Nothing, errSQLField = "row", errHaskellType = "Text", errMessage = "types incompatible"}
2021-08-23 22:08:44 <fresheyeball> The column has type text
2021-08-23 22:08:49 <fresheyeball> and the haskell type is Text
2021-08-23 22:08:53 <fresheyeball> I am at a loss
2021-08-23 22:09:25 <dminuoso> fresheyeball: can you show the code?
2021-08-23 22:09:55 <hpc> can the column be null?
2021-08-23 22:09:58 <fresheyeball> dminuoso: http://ix.io/3wMj
2021-08-23 22:10:05 <fresheyeball> no it cannot be null
2021-08-23 22:10:27 <fresheyeball> http://ix.io/3wMk
2021-08-23 22:10:31 <fresheyeball> this is the schema
2021-08-23 22:12:06 <dminuoso> fresheyeball: Is there valid utf8 in there?
2021-08-23 22:12:16 benin036932 joins (~benin@183.82.178.142)
2021-08-23 22:12:41 <dminuoso> I expect not.
2021-08-23 22:13:34 <fresheyeball> dminuoso: I am not sure, it's being generated by an Arbitrary instance
2021-08-23 22:14:07 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-08-23 22:14:19 <fresheyeball> ok I hard coded it to "user" and "pass" and the error persists
2021-08-23 22:14:23 <fresheyeball> those are both utf8
2021-08-23 22:15:27 × batch12 quits (~user@192.152.118.97) (Ping timeout: 240 seconds)
2021-08-23 22:17:21 <dminuoso> errSQLField = "row"
2021-08-23 22:17:37 <fresheyeball> ?
2021-08-23 22:18:12 <dminuoso> I find that curious
2021-08-23 22:18:19 <dminuoso> It should mention the column name
2021-08-23 22:18:58 <fresheyeball> It was the parens in the query
2021-08-23 22:19:19 <dminuoso> fresheyeball: Does this trigger on insert or select?
2021-08-23 22:19:28 <fresheyeball> select
2021-08-23 22:19:53 <dminuoso> 00:18:58 fresheyeball | It was the parens in the query
2021-08-23 22:19:55 <dminuoso> Yeah.
2021-08-23 22:19:59 <dminuoso> That explains it.
2021-08-23 22:20:30 <dminuoso> Also why there's no table oid, or SQLType "record"
2021-08-23 22:20:47 <fresheyeball> well onto the next error
2021-08-23 22:20:54 d0ku joins (~d0ku@37.30.113.168.nat.umts.dynamic.t-mobile.pl)
2021-08-23 22:21:06 <fresheyeball> apparently my createUser query doesn't make a user that is fount by my lookupHashByUsername function
2021-08-23 22:22:26 <dminuoso> fresheyeball: the order of columns is swapped around in the insert.
2021-08-23 22:22:33 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f)
2021-08-23 22:22:35 <fresheyeball> so
2021-08-23 22:22:39 <dminuoso> or not?
2021-08-23 22:22:52 <fresheyeball> I don't understand why it matters the order
2021-08-23 22:22:55 <fresheyeball> they are named
2021-08-23 22:23:20 <dminuoso> fresheyeball: what does the ToField instance for User look like?
2021-08-23 22:23:31 <fresheyeball> it's derived from a newtype of Text
2021-08-23 22:24:13 <dminuoso> Anyway. Enable debugging in your postgresql server
2021-08-23 22:24:20 <dminuoso> That way you can see what queries your database is actually getting
2021-08-23 22:24:25 <dminuoso> This can be a gods end with postgresql-simple
2021-08-23 22:26:27 <fresheyeball> well I looked in the db
2021-08-23 22:26:33 <fresheyeball> and there is in fact a user there
2021-08-23 22:26:35 <fresheyeball> oh shit
2021-08-23 22:26:37 <fresheyeball> I see
2021-08-23 22:26:51 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f) (Ping timeout: 250 seconds)
2021-08-23 22:27:23 <aegon> fresheyeball: does the flow your trying to emulate in haskell work in raw sql?
2021-08-23 22:27:31 <fresheyeball> user_name needs UNIQUE
2021-08-23 22:27:57 Lycurgus joins (~juan@cpe-45-46-140-49.buffalo.res.rr.com)
2021-08-23 22:28:31 <fresheyeball> ok tests run now atleast
2021-08-23 22:28:53 <dminuoso> fresheyeball: Btw, you might want to use cryptonite rather if security is important to you. :)
2021-08-23 22:29:06 <dminuoso> Argh
2021-08-23 22:29:09 <dminuoso> I meant libsodium,
2021-08-23 22:29:11 <fresheyeball> what is wrong with Data.Password.Argon2
2021-08-23 22:29:13 <fresheyeball> ?
2021-08-23 22:29:15 <dminuoso> Im really tired and need to go to bed.
2021-08-23 22:29:19 <dminuoso> No I meant libsodium
2021-08-23 22:29:35 <dminuoso> fresheyeball: libsodium is written by crypto experts with a keen focus on avoiding side channels
2021-08-23 22:29:35 <fresheyeball> well apparently Data.Password cannot handle all strings
2021-08-23 22:29:38 <dminuoso> all these haskell libraries are not.
2021-08-23 22:29:47 × d0ku quits (~d0ku@37.30.113.168.nat.umts.dynamic.t-mobile.pl) (Ping timeout: 240 seconds)
2021-08-23 22:30:40 <dminuoso> There's not even published papers on side channels in haskell semantics, the code that GHC produces, the way its optimized works, how this affects cache lines, CPU instructions, and everything
2021-08-23 22:31:44 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:71e9:72b:1860:cb0f)
2021-08-23 22:32:22 × Tuplanolla quits (~Tuplanoll@91-159-69-50.elisa-laajakaista.fi) (Quit: Leaving.)
2021-08-23 22:32:24 <fresheyeball> ok
2021-08-23 22:32:28 <fresheyeball> this is good enough for now
2021-08-23 22:32:31 <fresheyeball> I will look into it
2021-08-23 22:32:49 <fresheyeball> either way, it's actually the user check that is failing now
2021-08-23 22:32:58 <fresheyeball> "L\NUL'\"?Dk"
2021-08-23 22:32:59 <fresheyeball> expected: "L\NUL'\"?Dk"
2021-08-23 22:33:01 <fresheyeball> but got: "L"
2021-08-23 22:33:22 <fresheyeball> utf8 problem?
2021-08-23 22:34:19 <dminuoso> Postgresql does not permit NUL bytes in text

All times are in UTC.