Home liberachat/#haskell: Logs Calendar

Logs on 2024-07-21 (liberachat/#haskell)

00:00:34 smiesner joins (b0cf5acf8c@2a03:6000:1812:100::13b9)
00:04:40 <Lears> One is the other `flip`ped, so just choose one---it doesn't matter which.
00:04:50 <Lears> Better, give it a `Category` instance.
00:06:37 <Unicorn_Princess> flip would work for multiplication, albeit at slight user inconvenience, but not for division. curious about this Category thing tho, lemme look it up
00:07:09 × euleritian quits (~euleritia@dynamic-176-006-131-226.176.6.pool.telefonica.de) (Read error: Connection reset by peer)
00:07:20 <Unicorn_Princess> this thing? https://hackage.haskell.org/package/base-4.20.0.1/docs/Control-Category.html#t:Category
00:07:25 <Lears> Yes.
00:07:28 euleritian joins (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
00:08:06 <Unicorn_Princess> thanks
00:08:33 × Square2 quits (~Square@user/square) (Ping timeout: 252 seconds)
00:11:36 <Lears> Your needs are somewhat unclear, but I'd imagine `invert :: Qty a b -> Qty b a` and `qmul` would cover your bases for division.
00:16:42 × euleritian quits (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
00:16:53 euleritian joins (~euleritia@dynamic-176-006-131-226.176.6.pool.telefonica.de)
00:17:35 × euleritian quits (~euleritia@dynamic-176-006-131-226.176.6.pool.telefonica.de) (Read error: Connection reset by peer)
00:17:53 sss joins (~sss@dynamic-077-006-080-207.77.6.pool.telefonica.de)
00:17:58 <sss> hi
00:17:59 euleritian joins (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
00:19:40 × ash3en quits (~Thunderbi@2a01:c22:888e:9900:1578:4a37:8e5e:967) (Quit: ash3en)
00:21:01 <Unicorn_Princess> should i learn about arrows first before i go into the category typeclass?
00:21:54 <Unicorn_Princess> or is it the other way around..
00:22:53 <Lears> You should forget Arrow exists.
00:23:34 <Unicorn_Princess> oh dear
00:24:19 <Unicorn_Princess> having a hard time finding explanations on how to use Category tho, save for https://wiki.haskell.org/Typeclassopedia#Category
00:26:12 <Lears> Probably because there's nothing much to it. It just generalises associative composition with identity.
00:26:32 <Lears> Which you have with multiplication and dimensionless 1.
00:26:51 <sss> why should one forget about arrows?
00:27:24 <Lears> Well, not "multiplication" in general, but your restricted /cancelling/ multiplication.
00:30:22 <Lears> sss: One shouldn't necessarily forget about arrows in general, just the typeclass `Arrow`. It's something of a failed abstraction, but not beyond saving---there are various modern takes on it if you really want to investigate, but I haven't found any of them too compelling.
00:31:17 <ncf> Arrow is just Strong Category (https://hackage.haskell.org/package/profunctors-5.6.2/docs/Data-Profunctor-Strong.html)
00:33:15 × sss quits (~sss@dynamic-077-006-080-207.77.6.pool.telefonica.de) (Quit: leaving)
00:33:55 sss joins (~sss@dynamic-077-006-080-207.77.6.pool.telefonica.de)
00:34:19 <sss> Lears: ah I see
00:36:37 × squid64 quits (squid64@user/squid64) (Quit: Leaving)
00:37:22 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
00:37:53 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Client Quit)
00:39:16 squid64 joins (squid64@user/squid64)
00:42:19 aaronv joins (~aaronv@user/aaronv)
00:44:24 × squid64 quits (squid64@user/squid64) (Quit: Leaving)
00:47:22 × sss quits (~sss@dynamic-077-006-080-207.77.6.pool.telefonica.de) (Quit: leaving)
00:48:03 tomku joins (~tomku@user/tomku)
00:50:09 ash3en joins (~ash3en@2a01:c22:888e:9900:1578:4a37:8e5e:967)
00:50:51 × ash3en quits (~ash3en@2a01:c22:888e:9900:1578:4a37:8e5e:967) (Remote host closed the connection)
01:11:22 × Tuplanolla quits (~Tuplanoll@91-159-69-59.elisa-laajakaista.fi) (Quit: Leaving.)
01:27:03 dysthesis joins (~dysthesis@user/dysthesis)
01:38:26 × dysthesis quits (~dysthesis@user/dysthesis) (Remote host closed the connection)
01:44:04 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
01:52:26 × EvanR quits (~EvanR@user/evanr) (Quit: Leaving)
01:54:26 EvanR joins (~EvanR@user/evanr)
02:00:58 kupi joins (uid212005@id-212005.hampstead.irccloud.com)
02:05:04 × op_4 quits (~tslil@user/op-4/x-9116473) (Remote host closed the connection)
02:05:34 op_4 joins (~tslil@user/op-4/x-9116473)
02:19:09 × td_ quits (~td@i53870918.versanet.de) (Ping timeout: 276 seconds)
02:20:35 td_ joins (~td@i53870911.versanet.de)
02:21:22 masui333333 joins (~user@2601:646:8002:6ce0:2927:ebdb:a305:ef99)
02:44:12 × terrorjack quits (~terrorjac@2a01:4f8:c17:87f8::) (Quit: The Lounge - https://thelounge.chat)
02:47:06 terrorjack joins (~terrorjac@2a01:4f8:c17:87f8::)
03:02:26 × segfaultfizzbuzz quits (~segfaultf@23-93-79-84.fiber.dynamic.sonic.net) (Remote host closed the connection)
03:06:55 × Midjak quits (~MarciZ@82.66.147.146) (Quit: This computer has gone to sleep)
03:07:00 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 260 seconds)
03:09:46 × masui333333 quits (~user@2601:646:8002:6ce0:2927:ebdb:a305:ef99) (Remote host closed the connection)
03:20:50 cpressey joins (~weechat@176.254.71.203)
03:29:40 × Unicorn_Princess quits (~Unicorn_P@user/Unicorn-Princess/x-3540542) (Remote host closed the connection)
03:33:55 × phma quits (~phma@2001:5b0:210f:55a8:9fbe:3c54:a526:88c8) (Read error: Connection reset by peer)
03:34:19 phma joins (~phma@host-67-44-208-49.hnremote.net)
03:44:39 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
03:49:59 hiredman joins (~hiredman@frontier1.downey.family)
03:56:01 smalltalkman joins (uid545680@id-545680.hampstead.irccloud.com)
03:59:39 aforemny_ joins (~aforemny@2001:9e8:6cd3:7e00:62f7:f9a2:3af8:50bb)
04:00:21 × aforemny quits (~aforemny@2001:9e8:6cf3:7d00:7722:6259:6fe2:da4f) (Ping timeout: 248 seconds)
04:06:02 murasaki joins (~murasaki@104.234.142.145)
04:06:46 × murasaki quits (~murasaki@104.234.142.145) (Client Quit)
04:07:02 murasaki joins (~murasaki@104.234.142.145)
04:07:23 × murasaki quits (~murasaki@104.234.142.145) (Client Quit)
04:07:37 murasaki joins (~murasaki@104.234.142.145)
04:17:27 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 276 seconds)
04:24:03 × aaronv quits (~aaronv@user/aaronv) (Remote host closed the connection)
04:24:22 aaronv joins (~aaronv@user/aaronv)
04:30:40 × kupi quits (uid212005@id-212005.hampstead.irccloud.com) (Quit: Connection closed for inactivity)
04:36:18 × tomku quits (~tomku@user/tomku) (Ping timeout: 276 seconds)
04:36:32 tomku joins (~tomku@user/tomku)
04:53:45 × waleee quits (~waleee@h-176-10-144-38.NA.cust.bahnhof.se) (Ping timeout: 260 seconds)
05:03:01 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
05:09:04 × aaronv quits (~aaronv@user/aaronv) (Remote host closed the connection)
05:09:29 aaronv joins (~aaronv@user/aaronv)
05:18:13 × img quits (~img@user/img) (Quit: ZNC 1.8.2 - https://znc.in)
05:20:18 img joins (~img@user/img)
05:44:00 mreh joins (~matthew@lfbn-rou-1-646-109.w90-108.abo.wanadoo.fr)
05:47:40 rvalue- joins (~rvalue@user/rvalue)
05:48:05 × rvalue quits (~rvalue@user/rvalue) (Ping timeout: 252 seconds)
05:52:20 × hiecaq quits (~hiecaq@user/hiecaq) (Remote host closed the connection)
05:54:45 × pavonia quits (~user@user/siracusa) (Quit: Bye!)
05:55:26 × rvalue- quits (~rvalue@user/rvalue) (Ping timeout: 252 seconds)
06:14:19 <jackdk> Arrow is useful in some FRP contexts and in Opaleye but that's kinda about it. Many places where you might want to use Arrows hamstring you by requiring you to implement `arr`, which means you need to be able to arrow-ise arbitrary pure functions. There's some interesting work using linear functions with symmetric monoidal categories to get another take on "boxes and wires"-style diagrams, but it needs to mature a bit more.
06:14:29 × euphores quits (~SASL_euph@user/euphores) (Quit: Leaving.)
06:16:20 hiecaq joins (~hiecaq@user/hiecaq)
06:18:37 × hiecaq quits (~hiecaq@user/hiecaq) (Remote host closed the connection)
06:21:28 euphores joins (~SASL_euph@user/euphores)
06:23:01 rosco joins (~rosco@175.136.155.137)
06:25:05 rvalue joins (~rvalue@user/rvalue)
06:47:11 hiecaq joins (~hiecaq@user/hiecaq)
07:00:02 × tt123109783 quits (~tt1231@2603:6010:8700:4a81:219f:50d3:618a:a6ee) (Quit: The Lounge - https://thelounge.chat)
07:03:08 tt123109783 joins (~tt1231@2603:6010:8700:4a81:219f:50d3:618a:a6ee)
07:11:41 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
07:24:27 × tmr quits (~tamer@5.2.74.82) (Quit: "")
07:28:57 × murasaki quits (~murasaki@104.234.142.145) (Remote host closed the connection)
07:30:04 × mreh quits (~matthew@lfbn-rou-1-646-109.w90-108.abo.wanadoo.fr) (Quit: Lost terminal)
07:36:06 × chiselfuse quits (~chiselfus@user/chiselfuse) (Remote host closed the connection)
07:37:45 chiselfuse joins (~chiselfus@user/chiselfuse)
07:56:32 Lord_of_Life_ joins (~Lord@user/lord-of-life/x-2819915)
07:57:09 × Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 252 seconds)
07:57:09 × aaronv quits (~aaronv@user/aaronv) (Ping timeout: 276 seconds)
07:57:54 Lord_of_Life_ is now known as Lord_of_Life
08:05:05 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 260 seconds)
08:08:57 gmg joins (~user@user/gehmehgeh)
08:11:27 × skyesoss1 quits (~Thunderbi@c-73-208-45-119.hsd1.il.comcast.net) (Ping timeout: 252 seconds)
08:17:29 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
08:28:06 × rosco quits (~rosco@175.136.155.137) (Quit: Lost terminal)
08:34:43 misterfish joins (~misterfis@84.53.85.146)
08:38:34 amisto joins (~amisto@ec2-52-198-209-58.ap-northeast-1.compute.amazonaws.com)
08:40:05 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 260 seconds)
08:49:41 lxsameer joins (~lxsameer@Serene/lxsameer)
08:51:16 × amisto quits (~amisto@ec2-52-198-209-58.ap-northeast-1.compute.amazonaws.com) (Quit: Client closed)
08:53:30 × euleritian quits (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Ping timeout: 260 seconds)
08:53:45 euleritian joins (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
08:58:46 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Quit: ash3en)
08:59:01 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
09:07:13 __monty__ joins (~toonn@user/toonn)
09:12:10 × misterfish quits (~misterfis@84.53.85.146) (Ping timeout: 260 seconds)
09:15:02 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
09:23:23 Square2 joins (~Square@user/square)
09:23:25 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
09:25:52 misterfish joins (~misterfis@84.53.85.146)
09:26:21 cpressey joins (~weechat@176.254.71.203)
09:26:42 Tuplanolla joins (~Tuplanoll@91-159-69-59.elisa-laajakaista.fi)
09:27:44 × ThePenguin quits (~ThePengui@cust-95-80-24-166.csbnet.se) (Ping timeout: 260 seconds)
09:30:03 ThePenguin joins (~ThePengui@cust-95-80-24-166.csbnet.se)
09:31:24 × misterfish quits (~misterfis@84.53.85.146) (Ping timeout: 252 seconds)
09:35:44 sawilagar joins (~sawilagar@user/sawilagar)
09:37:29 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 245 seconds)
09:43:10 × tzh quits (~tzh@c-76-115-131-146.hsd1.or.comcast.net) (Quit: zzz)
09:44:36 × Sgeo quits (~Sgeo@user/sgeo) (Read error: Connection reset by peer)
09:49:54 tmr joins (~tamer@5.2.74.82)
09:53:25 × xff0x quits (~xff0x@2405:6580:b080:900:85a4:92a4:ce3d:c612) (Ping timeout: 248 seconds)
09:54:10 × lxsameer quits (~lxsameer@Serene/lxsameer) (Ping timeout: 260 seconds)
09:59:13 xff0x joins (~xff0x@2405:6580:b080:900:1ad7:bf8c:8156:7b85)
10:00:14 takuan joins (~takuan@178-116-218-225.access.telenet.be)
10:04:25 misterfish joins (~misterfis@046044172198.static.ipv4.heldenvannu.net)
10:05:10 oo_miguel joins (~Thunderbi@78.10.207.46)
10:24:29 × oo_miguel quits (~Thunderbi@78.10.207.46) (Quit: oo_miguel)
10:24:45 oo_miguel joins (~Thunderbi@78.10.207.46)
10:34:25 × Vajb quits (~Vajb@n85jaspk9c2pfwcdhy6-1.v6.elisa-mobile.fi) (Ping timeout: 248 seconds)
10:36:01 CiaoSen joins (~Jura@2a05:5800:25c:2700:e6b9:7aff:fe80:3d03)
10:40:50 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Ping timeout: 260 seconds)
11:00:50 cpressey joins (~weechat@176.254.71.203)
11:01:46 × mrmr1553343463 quits (~mrmr@user/mrmr) (Quit: Bye, See ya later!)
11:11:08 × misterfish quits (~misterfis@046044172198.static.ipv4.heldenvannu.net) (Ping timeout: 252 seconds)
11:14:00 mrmr1553343463 joins (~mrmr@user/mrmr)
11:14:39 misterfish joins (~misterfis@046044172198.static.ipv4.heldenvannu.net)
11:35:51 × lain` quits (lain`@user/lain/x-9874679) (Remote host closed the connection)
11:38:07 lain` joins (lain`@user/lain/x-9874679)
11:39:10 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 260 seconds)
11:41:24 × misterfish quits (~misterfis@046044172198.static.ipv4.heldenvannu.net) (Ping timeout: 276 seconds)
11:43:30 × CrunchyFlakes quits (~CrunchyFl@ip92348280.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
11:46:05 CrunchyFlakes joins (~CrunchyFl@146.52.130.128)
12:00:37 billchenchina- joins (~billchenc@223.39.206.205)
12:03:05 × euleritian quits (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Ping timeout: 260 seconds)
12:04:34 × smalltalkman quits (uid545680@id-545680.hampstead.irccloud.com) (Quit: Connection closed for inactivity)
12:04:45 euleritian joins (~euleritia@dynamic-176-006-177-193.176.6.pool.telefonica.de)
12:05:42 MadeleineSydney joins (~Thunderbi@c-71-229-185-228.hsd1.co.comcast.net)
12:07:01 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
12:07:17 × Katarushisu1 quits (~Katarushi@finc-20-b2-v4wan-169598-cust1799.vm7.cable.virginm.net) (Ping timeout: 248 seconds)
12:13:19 × euleritian quits (~euleritia@dynamic-176-006-177-193.176.6.pool.telefonica.de) (Read error: Connection reset by peer)
12:13:37 euleritian joins (~euleritia@77.22.252.56)
12:13:49 lxsameer joins (~lxsameer@Serene/lxsameer)
12:15:08 Katarushisu1 joins (~Katarushi@finc-20-b2-v4wan-169598-cust1799.vm7.cable.virginm.net)
12:20:33 cpressey joins (~weechat@176.254.71.203)
12:28:10 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 260 seconds)
12:30:00 JuanDaugherty joins (~juan@user/JuanDaugherty)
12:35:31 × FinnElija quits (~finn_elij@user/finn-elija/x-0085643) (Ping timeout: 260 seconds)
12:45:25 kenran joins (~user@user/kenran)
12:51:03 × puke quits (~puke@user/puke) (Remote host closed the connection)
12:51:25 puke joins (~puke@user/puke)
13:00:01 × euleritian quits (~euleritia@77.22.252.56) (Ping timeout: 252 seconds)
13:00:37 euleritian joins (~euleritia@dynamic-176-006-177-193.176.6.pool.telefonica.de)
13:03:31 misterfish joins (~misterfis@87.215.131.102)
13:03:44 waleee joins (~waleee@h-176-10-144-38.NA.cust.bahnhof.se)
13:06:09 zero is now known as zzz
13:11:25 pavonia joins (~user@user/siracusa)
13:16:46 × euleritian quits (~euleritia@dynamic-176-006-177-193.176.6.pool.telefonica.de) (Read error: Connection reset by peer)
13:17:04 euleritian joins (~euleritia@77.22.252.56)
13:20:57 madhavanmiui joins (~madhavanm@2409:40f4:101f:3e08:8000::)
13:22:16 × lain` quits (lain`@user/lain/x-9874679) (Remote host closed the connection)
13:25:08 lain` joins (lain`@user/lain/x-9874679)
13:25:43 FinnElija joins (~finn_elij@user/finn-elija/x-0085643)
13:27:05 × madhavanmiui quits (~madhavanm@2409:40f4:101f:3e08:8000::) (Remote host closed the connection)
13:28:03 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
13:29:52 × billchenchina- quits (~billchenc@223.39.206.205) (Remote host closed the connection)
13:32:11 × lain` quits (lain`@user/lain/x-9874679) (Remote host closed the connection)
13:34:02 lain` joins (lain`@user/lain/x-9874679)
13:39:59 × kenran quits (~user@user/kenran) (Remote host closed the connection)
13:43:23 danza joins (~francesco@151.57.181.229)
13:47:12 × JuanDaugherty quits (~juan@user/JuanDaugherty) (Quit: JuanDaugherty)
13:57:49 × lain` quits (lain`@user/lain/x-9874679) (Ping timeout: 260 seconds)
14:07:18 × CrunchyFlakes quits (~CrunchyFl@146.52.130.128) (Read error: Connection reset by peer)
14:10:06 CrunchyFlakes joins (~CrunchyFl@ip92348280.dynamic.kabel-deutschland.de)
14:11:04 danza_ joins (~francesco@151.57.181.229)
14:13:22 × danza quits (~francesco@151.57.181.229) (Ping timeout: 252 seconds)
14:17:15 × misterfish quits (~misterfis@87.215.131.102) (Ping timeout: 260 seconds)
14:18:43 szkl joins (uid110435@id-110435.uxbridge.irccloud.com)
14:19:06 misterfish joins (~misterfis@178.229.16.65)
14:27:38 <zzz> arrows are awesome, what are you talking about_
14:28:27 <Hecate> I'm not that fond of them but perhaps I'm also not the intended audience
14:30:37 × danza_ quits (~francesco@151.57.181.229) (Quit: Leaving)
14:33:45 <zzz> arrows remind me of how you think about control flow in array based languages
14:41:50 × noumenon quits (~noumenon@113.51-175-156.customer.lyse.net) (Read error: Connection reset by peer)
15:00:45 <EvanR> symmetric monoidal categories are awesome
15:01:03 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
15:01:03 <EvanR> then arrow jumps the shark in one place to make it not that
15:01:14 <c_wraith> as noted above, the big problem with Arrow as a class is that it requires you to implement `arr`, which means that all instances of it must contain haskell functions some way or another.
15:01:32 <c_wraith> which severely limits generality
15:02:54 × misterfish quits (~misterfis@178.229.16.65) (Ping timeout: 276 seconds)
15:15:06 noumenon joins (~noumenon@113.51-175-156.customer.lyse.net)
15:16:03 × lxsameer quits (~lxsameer@Serene/lxsameer) (Ping timeout: 252 seconds)
15:18:57 bitdex joins (~bitdex@gateway/tor-sasl/bitdex)
15:32:09 × __monty__ quits (~toonn@user/toonn) (Ping timeout: 276 seconds)
15:36:48 <ash3en> Can someone elaborate this?: "Because a parser combinator-based program is generally slower than a parser generator-based program, Parsec is normally used for small domain-specific languages, while Happy is used for compilers such as GHC." Where are the major or minor differences in parser combinators and parser generators?
15:36:50 cpressey joins (~weechat@176.254.71.203)
15:36:50 <ash3en> https://en.wikipedia.org/wiki/Parsec_(parser)
15:36:56 × bitdex quits (~bitdex@gateway/tor-sasl/bitdex) (Ping timeout: 260 seconds)
15:37:05 __monty__ joins (~toonn@user/toonn)
15:37:48 <ash3en> and tho Parsec is listed as a parser generator here: https://en.wikipedia.org/wiki/Category:Parser_generators and here https://en.wikipedia.org/wiki/Comparison_of_parser_generators
15:39:17 bitdex joins (~bitdex@gateway/tor-sasl/bitdex)
15:44:16 <tomsmeding> a "parser generator" such as happy is essentially a state machine; when compiled by a competent state machine generator and when written in such a way that the state machine executes efficiently in the target language (haskell in this case), they can be quite fast
15:44:56 <tomsmeding> Parsec is a parser combinator library and is not a "parser generator" in this sense; I would call it a parser library at most, though I can see how some people stretch the definition of "parser generator" to include parser combinator libraries
15:45:08 × tomku quits (~tomku@user/tomku) (Ping timeout: 255 seconds)
15:45:35 <tomsmeding> parser combinator libraries (including parsec) are really nothing more than a collection of well-chosen helper functions for writing a recursive-descent parser
15:46:12 <tomsmeding> they can be approximately as fast as a recursive descent parser can be, but typically those helper functions are more general in certain way than you need, making it harder to get optimal performance
15:46:50 <tomsmeding> production-grade parsers like those in GCC and Clang (for C and C++) are recursive-descent parsers for optimal freedom in generating parse errors, and hence good quality parser errors and recovery (given sufficient engineering effort)
15:47:01 tomku joins (~tomku@user/tomku)
15:47:40 <tomsmeding> parsec is an abstraction over recursive-descent parsing so that it's easier and quicker to write one, but at the cost of quality of error messages (typically) and some performance
15:47:45 <tomsmeding> ash3en: hope that helps a bit
15:48:04 <ash3en> tomsmeding: thank you! so shortened recursive-descent parsers are more efficient, parser generators are more high level and paresr combinators sit somewhere in between?
15:48:16 <ash3en> it really does, tomsmeding!
15:49:07 <tomsmeding> I would say parser combinators are more high-level than parser generators like happy, because with parser generators you're bound to essentially a context-free grammar, whereas with parser combinators you can do whatever you want
15:49:28 <tomsmeding> but you could also say they aren't comparable, because some things that are easy with parser generators are harder with parser combinators, and vice-versa
15:50:39 <Franciman> is there a way to compute the shapley value of an haskell program
15:50:41 <tomsmeding> the state machine algorithms that parser generators typically use have been a classical topic for optimisation, so they can be plenty fast as well -- I'm not sure how parser generators and recursive descent compaer in terms of performance
15:50:47 <Franciman> in terms of inconsistencies?
15:50:55 <tomsmeding> ash3en: w.r.t. parser generators, a keyword for a common variant is LALR
15:52:05 <monochrom> I think the keyword is "generally", which is in the statistical sense, not the "for all" sense.
15:53:29 <monochrom> "Generally", parser combinator libraries far exceed CFG, therefore must be slower.
15:53:43 <ash3en> tomsmeding: thanks for the insights
15:54:40 × CiaoSen quits (~Jura@2a05:5800:25c:2700:e6b9:7aff:fe80:3d03) (Ping timeout: 260 seconds)
15:54:54 <ash3en> monochrom: I have to think about this for a sec haha
15:57:34 × bastelfreak quits (bastelfrea@libera/staff/VoxPupuli.bastelfreak) (Quit: WeeChat 4.1.0)
16:17:14 × tomku quits (~tomku@user/tomku) (Ping timeout: 260 seconds)
16:17:28 tomku joins (~tomku@user/tomku)
16:22:06 danza joins (~francesco@151.57.161.108)
16:23:03 bastelfreak joins (bastelfrea@libera/staff/VoxPupuli.bastelfreak)
16:24:59 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Read error: Connection reset by peer)
16:35:47 lxsameer joins (~lxsameer@Serene/lxsameer)
16:37:03 <Athas> Hello Haskell people. In the near future, I will have to teach message passing-based concurrency using Haskell (but with principles similar to what you'd use in Erlang). Are there any good resources I should be aware of? I have written the following notes to demonstrate the kind of stuff I will want to talk about: https://github.com/diku-dk/ap-e2024-pub/blob/main/erlang.md
16:37:50 × Square2 quits (~Square@user/square) (Ping timeout: 260 seconds)
16:37:59 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
16:38:35 <geekosaur> aside from https://wiki.haskell.org/Cloud_Haskell?
16:39:05 <Athas> I did look at Cloud Haskell, but I discarded for a few reasons.
16:39:19 <Athas> One is that it is too complicated, and I don't need to teach production systems. It gets in the way of the concepts.
16:39:34 <Athas> Another is that the documentation isn't good enough to overcome the friction of using a production system.
16:43:59 lain` joins (lain`@user/lain/x-9874679)
16:46:31 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
16:50:00 × euleritian quits (~euleritia@77.22.252.56) (Read error: Connection reset by peer)
16:50:42 euleritian joins (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
16:51:26 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
16:51:33 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Client Quit)
16:52:37 aaronv joins (~aaronv@user/aaronv)
16:52:54 × oo_miguel quits (~Thunderbi@78.10.207.46) (Ping timeout: 245 seconds)
16:53:09 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 248 seconds)
16:54:02 <srk> Athas: ParConc is good resource https://simonmar.github.io/pages/pcph.html (you might want to talk about STM as well)
16:54:32 oo_miguel joins (~Thunderbi@78.10.207.46)
16:55:03 <Athas> I have considered talking about STM, if I can fit it in the curriculum, but right now my focus is on message passing, which that book doesn't talk much about.
16:55:33 <srk> Athas: in your document, you don't need explicit tail recursion but could use Control.Monad.forever
16:56:10 <srk> yeah, STM is quite generic
16:56:48 <srk> but similar patterns appear (request / response channels or t(m)vars)
16:57:27 <Athas> Control.Monad.forever means you can't shut down in response to a message.
16:57:40 <Athas> I prefer to keep it really explicit when writing teaching code, even if it does become very verbose.
16:58:19 <Athas> The better students will find concision on their own.
16:59:45 <srk> makes sense and yes you can't shut down based on message - you would need to terminate the thread. but erlang processes don't use shutdown-on-message functionality either iirc
17:00:35 <Athas> They do.
17:01:03 <Athas> Erlang processes are also just infinite loops.
17:01:09 <Athas> It's a nice operational model, really.
17:03:08 × mulk quits (~mulk@p5b112b2e.dip0.t-ipconnect.de) (Ping timeout: 252 seconds)
17:03:39 <srk> til! yes, it is, I often strugle to roll my own erlang in haskell :))
17:04:36 mulk joins (~mulk@p5b112b2e.dip0.t-ipconnect.de)
17:05:18 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
17:05:50 × MadeleineSydney quits (~Thunderbi@c-71-229-185-228.hsd1.co.comcast.net) (Ping timeout: 260 seconds)
17:09:55 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 260 seconds)
17:14:00 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
17:14:19 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
17:20:22 × lain` quits (lain`@user/lain/x-9874679) (Ping timeout: 252 seconds)
17:22:51 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
17:23:01 lain` joins (lain`@user/lain/x-9874679)
17:25:03 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
17:29:10 × lxsameer quits (~lxsameer@Serene/lxsameer) (Ping timeout: 260 seconds)
17:29:26 Achylles joins (~Achylles@45.182.57.38)
17:29:57 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Quit: ash3en)
17:33:14 <bwe> hi! I've made some change to my code and now I encounter a stack overflow by mapping over a list; undoing the change lets the stack overflow disappear; I am basically reading htmls from sqlite and parsing them. what should I look out for to find the cause of the stack overflow?
17:33:40 <bwe> …I've tried to trace it back with ghci debugger yet to no avail.
17:34:14 <geekosaur> stack overflows are often (usually?) caused by left recursion
17:34:55 <geekosaur> that is, a function invokes itself (possibly intending recursion) before doing anything else
17:35:44 <bwe> …then I should be able to count the function calls with the profiler and see the culprit?
17:36:07 × AlexZenon quits (~alzenon@94.233.241.102) (Ping timeout: 252 seconds)
17:36:22 <geekosaur> hopefully
17:37:07 × danza quits (~francesco@151.57.161.108) (Quit: life calls)
17:37:46 × euleritian quits (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
17:37:58 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 252 seconds)
17:38:35 euleritian joins (~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
17:38:45 <bwe> should I be able to trace it with ghci debugger?
17:40:01 <geekosaur> probably not
17:40:54 <geekosaur> the ghci debugger relies on the code allowing it to take control at some point, but this kind of recursion ends up being an uninterruptible loop
17:41:01 ash3en joins (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93)
17:41:30 × ash3en quits (~Thunderbi@2a01:c22:8d6b:b900:2b29:c04c:3cab:7f93) (Client Quit)
17:41:47 <geekosaur> theoretically a STG-level debugger would work, but (a) there isn't one (at least, not one usable with ghc) (b) it'd be kinda horrid to use
17:43:06 <dmj`> geekosaur: there's an STG debugger
17:43:27 <geekosaur> the one with STGi? doesn't work with ghc, which was the point of my parentetical
17:44:12 <dmj`> https://github.com/haskell-debugger/haskell-estgi-debugger this one is GHC compatible
17:44:47 <geekosaur> huh
17:44:50 <dmj`> it passes like over 70% of GHC's tests
17:45:22 <dmj`> geekosaur: ?
17:46:01 <geekosaur> I've been trying to keep an eye on developments in STGI-land but apparently missed that 😞
17:46:31 <dmj`> geekosaur: hasn't been advertised much tbh
17:46:42 <monochrom> Athas: MVar counts as message passing but very bounded queue (max length 1) >:). If you want unlimited length, can just use MChan or TChan.
17:46:57 <monochrom> or TQueue etc.
17:47:48 <Athas> monochrom: I use Control.Concurrent.Chan, and mostly because it's in base.
17:47:57 <monochrom> Yeah that works.
17:48:15 <monochrom> Oh! s/MChan/Chan/ heh, they never called it MChan.
17:48:25 <geekosaur> I was wondering…
17:48:40 <dmj`> geekosaur: it has a haskell implementation of the RTS too, includes a GC, scheduler, STM, most primops
17:49:16 <geekosaur> yeh, I looked it over quickly and I think I want to add that to my vscode setup 🙂
17:52:11 <dmj`> it's pretty cool, the STG syntax was altered so it looks monadic, but its very hard to map it back to the surface level haskell syntax
17:52:47 <dmj`> also, you'd need a GHC plugin to dump the IRs during builld time so the debugger can find them, or you might have to use the ghc fork
17:52:52 AlexZenon joins (~alzenon@94.233.241.102)
17:53:10 <monochrom> Influenced by my thesis supervisor, I prefer messages instead of shared vars for concurrency, too. :)
17:54:20 <geekosaur> in my case, I blame Tanenbaum (OSDI featuring Minix)
17:55:06 <monochrom> But I guess that influence traces back to Hoare and/or Milner, e.g., CSP = [easy-to-reason-about algebra of] concurrent sequential processes = locally sequential, exchange messages with others.
17:56:07 acidjnk joins (~acidjnk@p200300d6e72cfb2038b483e43bd9e2b7.dip0.t-ipconnect.de)
17:56:32 <monochrom> To some extent, imperative : functional :: shared vars : CSP or CCS or generally message passing
17:56:48 <stefan-__> any idea why an IHaskell kernel crashes with: 'ihaskell: No entry for "ld supports response files" in "~/.ghcup/ghc/9.6.4/lib/ghc-9.6.4/lib/settings"' ?
17:57:12 <monochrom> We know the right is the moral thing to do but the left is more obvious to people who are oh-so-close-to-bare-metal.
17:57:45 <monochrom> hell, s/more obvious/first instinct/ # and first instincts are usually wrong
17:58:15 cpressey joins (~weechat@176.254.71.203)
17:58:45 <monochrom> Someone needs to copy Backus and write "can concurrent programming be liberated from the von-Neumann SMP model?" >:)
17:59:06 <geekosaur> stefan-__, I don't see that entry in 9.6.5 or 9.6.6 settings files either
18:00:01 <geekosaur> it's not in 9.4.8 either
18:00:26 <Athas> You can implement shared variables in terms of message passing and get the worst of all worlds.
18:00:34 <Athas> What, after call, is an IORef but a stateful process?
18:00:40 <monochrom> That's what my supervisor says too :)
18:01:23 <stefan-__> geekosaur: could it be a mismatch with ghc from ghcup and the ghc version IHaskell has been compiled with via stack? (I tried to match both versions)
18:01:58 <geekosaur> possibly, but seems unlikely
18:02:12 <geekosaur> that said, I don't use stack so my references are all ghcup installs
18:04:39 misterfish joins (~misterfis@84.53.85.146)
18:05:09 <stefan-__> geekosaur: grml, after matching the ghc versions and recompiling+installing IHaskell, I didnt do a "ihaskell install --stack", doing this fixed it :)
18:08:28 × smiesner quits (b0cf5acf8c@2a03:6000:1812:100::13b9) (Remote host closed the connection)
18:14:59 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 255 seconds)
18:15:26 puke is now known as Guest327
18:15:26 pyooque joins (~puke@user/puke)
18:15:26 × Guest327 quits (~puke@user/puke) (Killed (erbium.libera.chat (Nickname regained by services)))
18:15:26 pyooque is now known as puke
18:17:15 <[exa]> is there some canonical tutorial for doing Generic instances for usual "convert&serialize" stuff? I managed to copy from aeson and from one SO post, but the ride wasn't very guided. So thought I could have a look to improve on things
18:17:49 <[exa]> s/Generic/Generic-using/
18:19:15 <dmj`> there used to be a ghc generics zoo tutorial somewhere
18:19:32 <dmj`> or just examples of different generic deriving
18:19:52 <dmj`> https://www.stephendiehl.com/posts/generics.html
18:20:31 smiesner joins (b0cf5acf8c@2a03:6000:1812:100::13b9)
18:20:47 <dmj`> D is for data type, C is for constructor, S is for selector,. + is sum, * is product, etc.
18:21:49 lxsameer joins (~lxsameer@Serene/lxsameer)
18:23:21 Square2 joins (~Square@user/square)
18:25:07 <[exa]> yeah that's okish, I was more confused about how to arrange the typeclasses
18:25:21 <davean> I mean there is also the GHC manual?
18:25:37 <[exa]> but yeah sdiehl one does it, thanks!
18:26:17 <davean> https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/generics.html
18:26:21 ddellacosta joins (~ddellacos@ool-44c73d29.dyn.optonline.net)
18:26:24 <[exa]> uoooh the manual I missed completely, it even has the section there
18:26:27 <[exa]> very good to know
18:26:38 <davean> the manual is *always* where the detailed explanation is
18:26:44 × sawilagar quits (~sawilagar@user/sawilagar) (Ping timeout: 260 seconds)
18:26:51 <davean> *always*
18:26:59 <davean> I do not get why people do not read it :(
18:28:02 <davean> I actually think Generics is one of the worst manual sections though
18:28:24 <davean> Its one of the few manual sections that leaves important details to a reference :(
18:29:23 cpressey joins (~weechat@176.254.71.203)
18:30:07 <bwe> geekosaur: recompiled with profiling on; however cabal run my-app -- -p does not create a .hp file
18:30:28 <bwe> (nor .prof file)
18:30:37 <haskellbridge> <sm> people forget the tools have good manuals/user guides (maybe because not all tools do). We could do more to promote them and make them easier to consult, eg from the tools themselves.
18:33:41 × tomku quits (~tomku@user/tomku) (Ping timeout: 252 seconds)
18:35:02 Sgeo joins (~Sgeo@user/sgeo)
18:36:51 × aaronv quits (~aaronv@user/aaronv) (Remote host closed the connection)
18:36:58 <tomsmeding> bwe: cabal run --enable-profiling my-app -- +RTS -p
18:37:13 aaronv joins (~aaronv@user/aaronv)
18:37:17 <tomsmeding> (the --enable-profiling is unnecessary if you have 'profiling: True' in cabal.project or similar)
18:38:06 × lxsameer quits (~lxsameer@Serene/lxsameer) (Ping timeout: 252 seconds)
18:40:26 tomku joins (~tomku@user/tomku)
18:41:32 <bwe> tomsmeding: ok, that makes sense now and is better: my-app.prof gets created, however remains during execution at size of 0.
18:41:55 <geekosaur> yes, in general the profile isn't actually output until the program exits
18:42:06 <bwe> tomsmeding: I want to find the left recursion that is causing the stack overflow.
18:42:20 <tomsmeding> I probably missed the point of the previous discussion, but what about adding some Debug.Trace.trace calls?
18:42:28 <geekosaur> it used to be the case that some kind of normal exit was required for it to be written; I know that was changed for signal handlers, I'm not sure about exceptions
18:43:45 <bwe> geekosaur: so, is there any special option to let it write the .prof during execution?
18:46:02 sawilagar joins (~sawilagar@user/sawilagar)
18:46:30 <geekosaur> I think you need to switch to profiling via events instead of a .prof file
18:48:10 <geekosaur> https://downloads.haskell.org/ghc/9.10.1/docs/users_guide/profiling.html#eventlog-profile-format
18:48:31 <geekosaur> that particular section doesn't say much but points to a section detailing the event log
18:48:53 <geekosaur> and there are RTS options controlling generation and output to the event log
18:52:47 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 255 seconds)
18:53:21 tomsmeding . o O ( Debug.Trace has never failed me )
18:53:26 destituion joins (~destituio@83-243-191-191.fth.tafjordconnect.net)
18:54:04 <geekosaur> I still want `ctcr` for Haskell
18:54:48 <bwe> I've generated a html with eventlog2html. It's no help. It shows only under heap some diagram. no insight as to which function is running a circular loop.
18:55:04 <bwe> +RTS -l -hc as parameters
18:55:17 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
18:55:24 × aaronv quits (~aaronv@user/aaronv) (Remote host closed the connection)
18:55:43 aaronv joins (~aaronv@user/aaronv)
18:55:46 <bwe> Can't I just break the execution with ctrl+c somehow and look at which location code execution stopped? in case of a loop I should be at the loop then.
18:56:13 <c_wraith> you might be able to get the ghci debugger to give you that info. I think it supports that.
18:56:16 <bwe> tomsmeding: I hear you :). Where to put them? It might be obvious for you but not for me...
18:56:44 <tomsmeding> at entry to every function that is potentially in the loop :p
18:56:53 <sprout> printf
18:57:05 <tomsmeding> hm, have you tried putting HasCallStack => on a bunch of functions and running with `+RTS -xc`?
18:57:13 <tomsmeding> maybe the HasCallStack is not even necessary
18:57:19 <tomsmeding> -xc will print tracebacks on exceptions
18:57:35 <tomsmeding> without HasCallStack the tracebacks will be very short, typically unusably short
18:57:42 <tomsmeding> but maybe you're lucky
18:57:43 × Achylles quits (~Achylles@45.182.57.38) (Quit: Leaving)
18:58:06 <tomsmeding> maybe it even shows a traceback on Ctrl+C!
18:58:22 <c_wraith> honestly, it's usually faster to just find the place where you're using a value in its own definition incorrectly by inspection
18:59:09 <geekosaur> hm, eventlog doesn't seem to log function entry
18:59:38 × esph quits (~weechat@user/esph) (Ping timeout: 258 seconds)
18:59:40 <c_wraith> does it log cost center entry?
19:00:14 <geekosaur> tbh I think I'd just annotate function entries with `trace`
19:00:27 <geekosaur> I'm uncertain, it might be https://downloads.haskell.org/ghc/9.10.1/docs/users_guide/eventlog-formats.html#cost-centre-break-down
19:01:26 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
19:01:55 <geekosaur> hack to trace function entries https://paste.tomsmeding.com/mF5Mg7as
19:02:33 <geekosaur> unlike profiling or (usually) the event log, this will be streamed because `stderr` is usually unbuffered
19:03:22 <tomsmeding> I feel like that guard trick should just be there in the Debug.Trace docs
19:03:56 <tomsmeding> it's too useful and perhaps just a little to weird to think up if you haven't seen it before
19:04:17 cpressey joins (~weechat@176.254.71.203)
19:04:19 <tomsmeding> *too weird
19:05:20 <tomsmeding> bwe: ^
19:06:52 <bwe> tomsmeding: `+RTS -xc` is running now
19:08:18 <bwe> tomsmeding: https://paste.tomsmeding.com/lgbxw2Mg
19:08:54 <bwe> geekosaur: It appears to be the utf8 unicode function you supported me in the last days.
19:09:07 <tomsmeding> told you the stack trace would be too short
19:09:31 <tomsmeding> bwe: beware that even if the stack overflow happens in some function f, f might not itself loop
19:09:45 <tomsmeding> it may be that in every iteration of the loop, f is called, f returns, and then the loop continues
19:09:46 <bwe> geekosaur: https://paste.tomsmeding.com/E5eZqA1Y
19:09:58 <bwe> tomsmeding: I've added the HasCallStack :)
19:10:13 <bwe> (I pasted only an excerpt)
19:10:36 tromp joins (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
19:13:50 <geekosaur> hm. there's no particular reason that should loop, unless it's the function calling utf8OrLatin1ToText that's looping
19:13:54 target_i joins (~target_i@user/target-i/x-6023099)
19:14:22 <geekosaur> (or there's a bug in `text` but one would think someone else would have run into it by now; it's very heavily used)
19:14:43 <c_wraith> it can loop if bs is a bottom
19:14:48 <c_wraith> and that's the most likely
19:14:49 <monochrom> I teach my students the guard trick too. :)
19:15:06 × misterfish quits (~misterfis@84.53.85.146) (Ping timeout: 276 seconds)
19:15:39 <bwe> c_wraith: can you elaborate, bs is a bottom?
19:15:58 <tomsmeding> c_wraith: then bs itself would loop, not this function, right?
19:16:10 <c_wraith> yes, but if this is the only place forcing bs..
19:16:22 <tomsmeding> then still this function should not be at the top of the call stack
19:16:30 <tomsmeding> whatever produced bs should be
19:16:48 <bwe> (bs is html)
19:17:45 <tomsmeding> bwe: what if you put two traces at the start of this function: first say "entered foo", then with a second trace print the length of bs
19:17:47 <bwe> tomsmeding: how can I further trace it down to the actual thing that loops? it makes no sense to me that the utf8OrLatin1ToText is causing it.
19:17:59 <tomsmeding> s/foo/utf8OrLatin1ToText
19:18:18 <tomsmeding> if this function indeed loops, then you should see both many times
19:18:31 <tomsmeding> if the evaluation of bs loops, then you should see a stack overflow after the first trace
19:18:47 <tomsmeding> if the problem is not actually here, you should see both perhaps a few times and that's it
19:19:08 <tomsmeding> though if you see both many times it might still mean that the looping function calls this as a subroutine
19:20:00 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 260 seconds)
19:20:44 <bwe> tomsmeding: where would you like me to put the second trace? https://paste.tomsmeding.com/7XMCQfKf
19:21:08 CiaoSen joins (~Jura@2a05:5800:25c:2700:e6b9:7aff:fe80:3d03)
19:22:10 <tomsmeding> bwe: https://paste.tomsmeding.com/Lkz6i32O
19:22:26 <tomsmeding> oh BL, not BS
19:23:21 <bwe> tomsmeding: fixed
19:24:22 <bwe> here we go: https://paste.tomsmeding.com/g9j6YrPp
19:24:36 <tomsmeding> looking good
19:24:37 <bwe> it does not emit any new line after the one with 166
19:24:51 <tomsmeding> any "entered" lines?
19:25:37 <bwe> only a single one right after the executable starts
19:25:45 <tomsmeding> oh meh
19:26:19 <bwe> decode "oh meh" pls :)
19:27:09 <tomsmeding> bwe: what if you do this https://paste.tomsmeding.com/zSj7QRhh
19:27:40 <tomsmeding> "oh meh" was "my trace trick didn't work, laziness was too clever"
19:27:51 <tomsmeding> I'm now trying to out-clever laziness
19:28:47 cpressey joins (~weechat@176.254.71.203)
19:29:16 <bwe> c_wraith: I don't see anything that gives me the slightest idea of how to manually break the program with ghci at the loop and see the location then: https://downloads.haskell.org/ghc/9.10.1/docs/users_guide/ghci.html#tracing-and-history -- is there?
19:29:42 <bwe> tomsmeding: laziness outclevered you :0
19:29:57 <bwe> (same output, only single entered…)
19:31:40 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 260 seconds)
19:31:52 <c_wraith> I still don't understand why you haven't just found it by inspecting the diff between the previously working code and the refactored broken code
19:34:08 <tomsmeding> bwe: add {-# OPTIONS -fno-full-laziness #-} to the top of the file containing this function, then you can also undo the entermsg trick
19:34:37 <tomsmeding> (if we can't outsmart laziness, let's disable it)
19:34:46 <tomsmeding> (partly)
19:35:29 <tomsmeding> bwe: how large is the diff between the working and non-working version of your code (re c_wraith's comment)
19:36:25 <bwe> c_wraith: Me neither.
19:37:05 <bwe> c_wraith: I went through the code by inspection already without success. Now adding traces to the functions I changed / created.
19:37:13 <bwe> tomsmeding: Didn't change a bit.
19:37:33 <bwe> tomsmeding: Let me double check.
19:37:52 <tomsmeding> https://play.haskell.org/saved/4ydRiXrh
19:39:08 <bwe> tomsmeding: https://paste.tomsmeding.com/PXv5sukl
19:40:30 <tomsmeding> add two more traces after the length one, one with `show (decodeUtf8' bs)` and one with `show (decodeLatin1 bs)`
19:40:52 <tomsmeding> likely you'll just see a pair of those for every call as well, meaning that the problem is not here
19:48:43 <bwe> I've found the two functions that are calling each other!
19:48:49 <tomsmeding> indefinitely?
19:48:54 <bwe> tomsmeding: It's not the decodeUtf8
19:49:16 <bwe> tomsmeding: I've put a trace in each of them and they alternate once the loop is happening.
19:49:23 <tomsmeding> great
19:49:51 <bwe> c_wraith: thanks for re-inviting me into the manual inspection. and thanks to tomsmeding for the trace idea. I value this from hereon!
19:50:30 econo_ joins (uid147250@id-147250.tinside.irccloud.com)
19:50:56 <bwe> I deeply miss a writeup of how experienced Haskellers debug their problems, like a cookbook. that wisdom seems to be buried in your heads - or did I miss a treasure trove online?
19:51:52 <tomsmeding> I don't think you missed anything
19:51:57 puke is now known as Guest3837
19:51:57 pyooque joins (~puke@user/puke)
19:51:57 × Guest3837 quits (~puke@user/puke) (Killed (copper.libera.chat (Nickname regained by services)))
19:51:57 pyooque is now known as puke
19:52:43 ashleyNeedsAdvic joins (~ashleyNee@216.209.150.45)
19:52:45 <tomsmeding> there are apparently some notes on using ghci for debugging loops here https://wiki.haskell.org/Debugging#Infinite_loops
19:52:54 <tomsmeding> (not sure how well that works in practice)
19:53:12 × puke quits (~puke@user/puke) (Max SendQ exceeded)
19:53:58 × ashleyNeedsAdvic quits (~ashleyNee@216.209.150.45) (Write error: Broken pipe)
19:54:22 × cassiopea quits (~cassiopea@user/cassiopea) (Ping timeout: 252 seconds)
19:54:25 puke joins (~puke@user/puke)
19:55:09 × phma quits (~phma@host-67-44-208-49.hnremote.net) (Read error: Connection reset by peer)
19:55:39 × puke quits (~puke@user/puke) (Max SendQ exceeded)
19:56:12 phma joins (~phma@2001:5b0:212a:d468:e9b2:3bc1:1a12:92a8)
19:56:47 <bwe> tomsmeding: that was the thing I was doing and not getting any further, I got misled by the decode functions there…
19:56:55 puke joins (~puke@user/puke)
19:57:18 <tomsmeding> ah :)
19:57:41 tomsmeding is glad that the poor man's method of trace debugging still wins out
19:57:49 tomsmeding has rarely done anything else
19:59:01 <Rembane> I love that when things become a bit more complex, trace debugging is the only thing working
19:59:53 × smiesner quits (b0cf5acf8c@2a03:6000:1812:100::13b9) (Changing host)
19:59:53 smiesner joins (b0cf5acf8c@user/smiesner)
20:02:20 <bwe> tomsmeding: Actually I recently felt like such a thing to print some stuff without IO…and am glad for learning about trace this way.
20:02:39 <tomsmeding> it's a bit difficult to handle in haskell sometimes because of laziness
20:02:48 <tomsmeding> but printf debugging still reigns
20:03:03 <haskellbridge> <mauke> "a refreshing desert in the oasis of referential transparency"
20:03:51 <bwe> tomsmeding: and the beauty is that I don't need to do profiling if I can resort to trace.
20:03:59 <monochrom> Not convinced "cookbook" is the right metphor for debugging. More like "repair manual".
20:04:13 <bwe> tomsmeding: now you make me interested in printf
20:04:28 <bwe> monochrom: of course.
20:04:41 <tomsmeding> ("printf debugging" is the name for this in C land, where the standard printing function is called 'printf')
20:04:52 <tomsmeding> (C is older than Haskell, so "printf debugging" stuck)
20:05:26 <monochrom> Like, if your cake comes out overburned, bitter, dry, and unfinished, a cookbook doesn't tell you how to repair the cake, a cookbook tells you "throw that away, now follow these proper steps properly to make a new one".
20:05:57 <tomsmeding> given reality, though, a cookbook for software had better teach you how to fix your software
20:07:01 <__monty__> I do wish I was skilled at the use of the GHCi debugger. It's probably a lot more ergonomic than adding trace calls in a bunch of places and generating yourself a ridiculously long log of things to sift through.
20:07:37 <monochrom> I do not always believe in ESR's bazaar model "release early, release often". However, debug early, debug often is always right.
20:07:38 <bwe> how much of your time in % do you spend on repairing?
20:08:11 <monochrom> I have never needed to debug my own 1000-line code because I never waited that long before testing.
20:08:50 <bwe> btw would rust detect the cause of the loop automagically or would I need to find it on my own?
20:09:08 <geekosaur> didn't Ritchie say something about more time spent debugging than writing code?
20:10:08 <tomsmeding> bwe: if it was a "value is defined in terms of itself" loop, then any non-lazy language would detect that
20:10:11 <bwe> so why no one writes those repair books?
20:10:28 <bwe> tomsmeding: so, laziness is the root of all evil?
20:10:31 <tomsmeding> if it was an "infinite recursion" loop, only languages with a termination checker such as Agda detect that -- at a price
20:10:32 <monochrom> Economics.
20:10:54 <tomsmeding> bwe: laziness has advantages and disadvantages
20:11:03 <bwe> tomsmeding: but still, I'd then need only a switch (turn all laziness off), then Haskell would find that, too?
20:11:05 <tomsmeding> it is also the root of a lot of good things
20:11:18 <tomsmeding> that's called {-# LANGUAGE Strict #-}, though it's not perfect
20:11:24 <bwe> I'd just turn that on if I am debugging a loop :)
20:11:26 <tomsmeding> (and only applies to that module)
20:11:41 <tomsmeding> it essentially adds lots of bang patterns everywhere
20:11:43 <bwe> tomsmeding: but Haskell is then not telling me about the loopV?
20:12:01 <monochrom> If you don't understand laziness than you don't understand Strict either.
20:12:04 <tomsmeding> bwe: if you really define a value directly in terms of itself, the runtime system will complain
20:12:10 <tomsmeding> % let x = x :: Int in x
20:12:12 <yahb2> <timeout>
20:12:14 <tomsmeding> oh
20:12:18 <tomsmeding> okay with optimisations then
20:12:23 <tomsmeding> ("<<loop>>")
20:12:29 <monochrom> here "understand" means you can make right-on predictions.
20:12:42 <tomsmeding> right, -XStrict is almost never what you want
20:12:42 <haskellbridge> <sm> __monty__: I don't think it is. Keep in mind you can insert and move tactical trace calls while reloading with ghci[d]
20:13:35 <bwe> tomsmeding: but two functions calling each other like in my case?
20:13:49 × L29Ah quits (~L29Ah@wikipedia/L29Ah) (Ping timeout: 244 seconds)
20:14:03 <bwe> also, on debugging what bugs me is the absence of hot reloading
20:14:08 <geekosaur> I don't think anything can help with that, really
20:14:09 <tomsmeding> there are many cases of mutual recursion that are perfectly fine
20:14:09 <monochrom> But last time I had to debug someone else's code, I found that working backwards works better.
20:14:24 <bwe> I need to re run half of the history in ghci after I changed a bit on my code.
20:14:29 <tomsmeding> how's ghc to know that this particular case is bad?
20:14:31 <bwe> how do you approach that personally?
20:14:42 <tomsmeding> put your ghci commands in a file :p
20:15:02 <monochrom> That was C code. But still, I'm rusty with gdb, so I still used printf debugging. I would say even with gdb I would still be working backwards.
20:15:25 <tomsmeding> gdb also only shows you want you tell it to show you
20:15:35 <tomsmeding> if you don't know where to look, gdb (or any debugger) isn't going to tell you
20:15:36 <geekosaur> these days C even has a debugger that works that way: rr
20:15:48 <geekosaur> sadly, Haskell code generally confuses it too much and it crashes
20:15:53 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
20:15:57 <__monty__> sm: Last time I ended up in this situation was AoC. And the problem did not occur until deep into the iterations but I did need a handful of lines of context for the problematic iteration. I think I made the tracing conditional on the iteration in the end.
20:16:13 <monochrom> Basically gdb saves you from "every time I add/change a printf I have to recompile". :)
20:16:35 <monochrom> OTOH gdb is great for stack trace after segfault and coredump.
20:17:26 <bwe> tomsmeding: but that's not really ergonomic at all, isn't it? that's the one thing I find myself doing over and over again. it's just wasting time.
20:17:38 <bwe> any chance for hot reloading coming to Haskell?
20:17:44 <__monty__> Debuggers can also move the decision of where to put traces to in the middle of execution time, which can be pretty nice.
20:17:56 <tomsmeding> bwe: probably not
20:18:03 <tomsmeding> but you can copy a single function into ghci
20:18:12 <tomsmeding> :{ starts a multiline ghci command, :} ends it
20:18:29 <tomsmeding> the function won't be picked up by other things already in the module, though
20:20:16 <bwe> __monty__: for ghci I know of `:trace fun` syntax -- how can I give it a name that gets printed when its reached?
20:23:03 <__monty__> I *know* the answer to this quiz, give me just a second.
20:23:49 <bwe> thanks for your support tomsmeding geekosaur c_wraith monochrom -- we finally traced it with trace :)
20:24:56 <tomsmeding> :)
20:25:00 <tomsmeding> have fun haskelling
20:25:43 <monochrom> Hot take: A "debugging cookbook" or "code repair manual" is otherwise known as "a course on the scientific method" or "a course on the philosophy of science".
20:26:08 <monochrom> For starters, most programmers don't yet know to fight their own confirmation bias in the first place.
20:26:22 <monochrom> (That would be like 80% of the battle already.)
20:26:22 <bwe> monochrom: there you already have a title and subtitle for your book :).
20:26:27 <__monty__> Hmm, `:set stop :list` is the example from the manual I was thinking of. That tells GHCi to run `:list` every time it stops at a breakpoint. You might be able to coerce that into what you want maybe, somehow? Problem is it may not actually work with tracing, I'm not sure.
20:27:02 <bwe> tomsmeding: thanks for making it possible
20:28:37 <monochrom> Those courses already exist. No one needs write one more book.
20:29:38 <monochrom> One just needs to not disdain course codes that begin with PHL.
20:29:50 <tomsmeding> I doubt one needs a whole book or course to get enough of the idea of testing hypotheses and countering biases to proceed into "how to I practically debug in this language"
20:30:07 <tomsmeding> like, I'm not saying that this content is not useful
20:30:25 <monochrom> Oh, you mean s/one/one who already has a scientific mind/
20:30:35 <tomsmeding> but I suspect that a book or course on the subject will give you many details that are not useful for learning debugging
20:30:48 <bwe> monochrom: So what's then the subtle yet potential impactful difference between "how to debug in this language" vs. "course on the scientific method"?
20:31:24 <haskellbridge> <sm> be aware of the breakpoint lib also, it's in between trace and an interactive debugger
20:31:31 <monochrom> What difference? I even use the scientific method to learn those languages in the first place.
20:31:33 <bwe> for me the recurring pattern is making things visible that haven't been before. and that's exactly what trace does.
20:32:15 <tomsmeding> bwe: I think what monochrom means is that there is an underlying philosophy of debugging that transcends languages
20:32:31 <tomsmeding> and that is essentially "don't think you know a thing before you've tested it experimentally"
20:32:52 <tomsmeding> after that, you still have to figure out that e.g. ':trace' exists
20:32:59 <bwe> <sm> "While GHCi has built-in support for setting breakpoints, it is not actively maintained and suffers from several critical limitations:"
20:33:09 <tomsmeding> but those are two different competencies
20:33:10 <bwe> tomsmeding: ofc
20:33:23 <tomsmeding> and you need both
20:33:34 <tomsmeding> the latter you can get from a manual, the former is harder to get from a manual
20:34:05 × peterbecich quits (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 260 seconds)
20:34:18 <bwe> tomsmeding: that reminds me of rubber ducking. if you explain everything to a random guy, you do start from zero, including re-expressing the basics of the basics, those you wouldn't question. and by the very fact of expressing them you uncover your own flawed assumptions.
20:34:23 L29Ah joins (~L29Ah@wikipedia/L29Ah)
20:34:36 <bwe> ^^ regarding bias busting
20:34:47 <tomsmeding> I have a collection of literal rubber ducks
20:35:09 <bwe> tomsmeding: pictures!
20:35:17 tomsmeding grumbles
20:35:41 <bwe> <sm> do you speak from your experience using it?
20:36:00 <haskellbridge> <sm> bwe: (I wasn't speaking of those, to be clear)
20:36:34 × [_________] quits (~oos95GWG@user/oos95GWG) (Quit: [_________])
20:36:45 <haskellbridge> <sm> bwe the breakpoint lib ? yes I tried it a little
20:37:12 <bwe> <sm> so has it become your default? when are you using it, still?
20:37:22 <tomsmeding> bwe: https://tomsmeding.com/vang/adlAkQ/PXL_20240721_203612023.jpg
20:37:57 <bwe> tomsmeding: do they have names? which do you speak to at which debugging situation?
20:38:14 <tomsmeding> unfortunately no they do not have names :p
20:38:33 <monochrom> One of them ought to be called Mr. Penguin. :)
20:38:45 <haskellbridge> <sm> no, trace (souped up by my own helpers) is my default, which I use often. breakpoint had some problem for me which I've forgotten
20:38:59 <tomsmeding> there is indeed a penguin duck in there, but on the far right there's also a glass puffin
20:39:07 <bwe> tomsmeding: just look at the five? tiny ones!
20:39:28 <bwe> <sm> trace rulez
20:39:31 <tomsmeding> https://tomsmeding.com/ss/get/tomsmeding/nqSTKP
20:40:00 <bwe> tomsmeding: you could create emojis from those…duck only
20:40:22 <bwe> tomsmeding: I like that shark duck.
20:40:25 [_________] joins (~oos95GWG@user/oos95GWG)
20:40:43 <bwe> where did you get that from?
20:41:25 <tomsmeding> https://www.badeendwinkel.nl/nl/lilalu/1733-badeend-haai-lilalu.html
20:42:44 <monochrom> I didn't know that ducks celebrate halloween too >:)
20:42:47 bwe observes the remaining stock to see how many in this channel will silently order it.
20:43:10 <tomsmeding> lol, the "lilalu" is a brand name so presumably it's also sold elsewhere
20:44:48 × cpressey quits (~weechat@176.254.71.203) (Ping timeout: 276 seconds)
20:45:12 cpressey joins (~weechat@176.254.71.203)
20:45:52 <bwe> interesting, the NL shop is way cheaper than the producer's online shop
20:47:16 <tomsmeding> this is the kind of thing that drops down in price hugely when you buy it in bulk
20:49:54 <bwe> wishing you good night in bathing ducks world…
20:56:26 dysthesis joins (~dysthesis@user/dysthesis)
20:57:05 × puke quits (~puke@user/puke) (Remote host closed the connection)
20:57:25 puke joins (~puke@user/puke)
21:02:22 × dysthesis quits (~dysthesis@user/dysthesis) (Remote host closed the connection)
21:05:51 dysthesis joins (~dysthesis@user/dysthesis)
21:11:11 × dysthesis quits (~dysthesis@user/dysthesis) (Ping timeout: 260 seconds)
21:12:57 dysthesis joins (~dysthesis@user/dysthesis)
21:21:26 Midjak joins (~MarciZ@82.66.147.146)
21:22:29 × acidjnk quits (~acidjnk@p200300d6e72cfb2038b483e43bd9e2b7.dip0.t-ipconnect.de) (Ping timeout: 248 seconds)
21:34:14 × tromp quits (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
21:39:08 omentic joins (~apropos@104.193.135.206)
21:40:09 <omentic> hi all, total beginner at haskell
21:40:28 <ddellacosta> omentic: welcome
21:41:13 <omentic> i'm trying to debug print a term to figure out what it's doing. is there some sort of `dbg` function i can use without running into purity issues, and is there some sort of `todo` function so i can debug print and then quit?
21:41:41 <ddellacosta> omome
21:41:57 <ddellacosta> d'oh mistake, sorry
21:42:13 <ddellacosta> omentic: take a look at trace or traceM, depending on context https://hackage.haskell.org/package/base-4.20.0.1/docs/Debug-Trace.html#v:trace
21:42:31 <ddellacosta> I'm also fond of https://hackage.haskell.org/package/pretty-simple-4.1.2.0/docs/Debug-Pretty-Simple.html
21:42:41 <ddellacosta> adds a bit of nice formatting to the mix
21:42:52 × __monty__ quits (~toonn@user/toonn) (Quit: leaving)
21:43:10 <ddellacosta> omentic: elixir programmer btw? :-D
21:43:26 <omentic> ddellacosta: ah ty - i found trace but it seems to only take a String and i've been having trouble converting an arbitrary type to it
21:43:35 <omentic> ddellacosta: rust :-D
21:43:39 <ddellacosta> omentic: you're still going to need stuff that you can `show`, to be clear
21:43:44 <mauke> trace (show x)
21:43:51 <ddellacosta> ^
21:44:03 <ddellacosta> ah gotcha
21:44:08 <omentic> ooh ty
21:44:30 <mauke> :t error
21:44:31 <lambdabot> [Char] -> a
21:44:55 <mauke> > error (show 2) + 3
21:44:56 <lambdabot> *Exception: 2
21:44:57 <monochrom> See my https://www.vex.net/~trebla/haskell/tracing.html for more ways to use Debug.Trace
21:46:00 <omentic> is there a Bottom term or smth to immediately panic a function? like a todo or a hole
21:46:19 <ddellacosta> that's what mauke was showing w/error ^
21:47:30 <omentic> ohh thanks
21:47:32 <ddellacosta> https://hackage.haskell.org/package/base-4.20.0.1/docs/Prelude.html#v:error
21:50:27 × aaronv quits (~aaronv@user/aaronv) (Ping timeout: 276 seconds)
21:50:42 <omentic> oh dang "no instance for show X". unfortunate
21:50:54 <omentic> is there an autoderive or do i need to implement it directly?
21:51:07 <ddellacosta> want to share some code? Depends on what you're trying to derive
21:51:54 <omentic> yeah, i'm just working with hakyll
21:52:01 <omentic> trying to debug print this Context https://hackage.haskell.org/package/hakyll-4.16.2.2/docs/src/Hakyll.Web.Template.Context.html#ContextField
21:52:10 <ddellacosta> but you can try deriving (Show)
21:52:30 gehmehgeh joins (~user@user/gehmehgeh)
21:52:47 <ddellacosta> you probably can't derive that without clobbering a somehow
21:52:58 <ddellacosta> er, the type variable I mean
21:53:24 <omentic> somehow? is that a type
21:53:46 × gmg quits (~user@user/gehmehgeh) (Ping timeout: 260 seconds)
21:54:23 <omentic> also is deriving (Show) only for locally defined types?
21:55:26 × Tuplanolla quits (~Tuplanoll@91-159-69-59.elisa-laajakaista.fi) (Quit: Leaving.)
21:55:52 <ddellacosta> oh yeah, I was thinking of this as if you were writing it which of course is not the case
21:56:19 <ddellacosta> you can create an orphan instance locally I guess, which I think is fine as long as it's not library code you're releasing
21:56:22 <omentic> ah yeah i probably should have opened with that
21:56:35 <omentic> hmm ok will try
21:56:44 <ddellacosta> but before that I'd ask what you're trying to debug, because there may be a better way to approach it without that
21:57:42 <omentic> rn i'm basically just mucking about trying to figure out how hakyll works
21:58:00 <omentic> the default hakyll template provided is almost everything i want out of a static site generator, but not quite
21:58:35 <omentic> i have a bunch of markdown files with front matter like `--- layout: post\n title: XXX\n ---`
21:59:36 <omentic> somewhere in the hakyll engine that front matter is parsed as metadata by pandoc and so should be inspectable, so i should be able to pick an html template by matching on it (the hakyll default assumes ppl want different templates based on file paths)
21:59:59 × tomku quits (~tomku@user/tomku) (Ping timeout: 245 seconds)
22:00:02 <omentic> only problem is idk where that is so i'm trying to print debug all the relevant terms and find out where it might be
22:00:11 tomku joins (~tomku@user/tomku)
22:01:03 <ddellacosta> I see
22:01:46 <monochrom> You can try standalone deriving. If that is not an option, you can write your own X->String function.
22:04:28 <ddellacosta> oh that's a good point, you can just write a straightforward serialization function
22:12:39 <omentic> hrm. Context appears to be generic over a type
22:13:24 <omentic> which i think throws a wrench in the serialization function??
22:14:56 <omentic> oh wait, this is generic but then used in Item a, and Item a has show defined on it nvm
22:15:36 <Hecate> https://discourse.haskell.org/t/maintain-a-golden-test-of-your-packages-api-with-diff-package-api-and-print-api/9997
22:15:39 <Hecate> enjoy
22:23:26 <ddellacosta> omentic: yeah I assume you should be able to write a function that returns one string for a Context String vs. a Context _anythingElse, but I'm not super familiar with existentials. Hopefully someone else on here can give you better advice if you get stuck on that bit
22:25:14 × omentic quits (~apropos@104.193.135.206) (Quit: Lost terminal)
22:25:31 <ddellacosta> also, maybe Template has what you are looking for? and that has a Show instance https://hackage.haskell.org/package/hakyll-4.16.2.2/docs/Hakyll-Web-Template-Internal.html
22:25:49 omentic joins (~apropos@104.193.135.206)
22:26:11 <ddellacosta> not sure if you should rely on an Internal API other than for debugging to be clear
22:29:45 <omentic> ok i'm kinda confused about this newtype syntax
22:29:56 <omentic> why is ex. a newtype declaration this: newtype Context a = Context { unContext :: String -> [String] -> Item a -> Compiler ContextField }
22:30:06 <omentic> and not this? newtype Context a = String -> [String] -> Item a -> Compiler ContextField
22:30:19 <c_wraith> It's using record syntax to declare an accessor at the same time
22:30:40 <c_wraith> That's perfectly valid, as long as the record only has one field.
22:30:43 × takuan quits (~takuan@178-116-218-225.access.telenet.be) (Remote host closed the connection)
22:31:40 machinedgod joins (~machinedg@d173-183-246-216.abhsia.telus.net)
22:32:22 <omentic> hmm
22:33:03 <c_wraith> also, your suggested alternative doesn't contain a constructor
22:33:08 <c_wraith> newtypes always have constructors
22:33:39 <omentic> ok so i guess, what is the structure of the Context type?
22:33:44 <c_wraith> it would be like newtype Context a = Context (String -> [String] -> Item a -> Compiler ContextField)
22:34:20 <c_wraith> that creates the exact same type, it just doesn't also create a value named unContext to extract the value
22:34:34 <omentic> why is Context in there twice? what's the = Context for
22:35:00 <c_wraith> newtype TypeName = ConstructorName ContentType
22:35:15 <c_wraith> Types and constructors are separate namespaces, so it's common to reuse the same name
22:35:32 <c_wraith> as the example you initially quoted does
22:35:34 <omentic> also unContext is returning... a function that takes in a String, a list of Strings, and an Item and returning the Compiler ContextField right (as a sanity check)
22:36:15 <c_wraith> yeah, unContext actually has an annoying type, because it's not the type specified afterwards. That's kind of a failing of record syntax.
22:36:20 <omentic> ok i see interesting, ig i'm used to the constructor name being implicit. that's cool
22:37:00 <c_wraith> Well, it's like constructor names for data, as well. for instance, data Bool = False | True
22:37:12 <c_wraith> Two different constructors, each creates a Bool value
22:37:23 <c_wraith> But a newtype can only have one constructor.
22:37:57 <omentic> 👍
22:38:44 <omentic> hmm can you explain unContext a little more
22:39:38 <c_wraith> Well. uncontext is technically a "field selector". Field selectors can work in several different ways
22:40:20 <c_wraith> In the specific way it's being used there, the only really important one is that a field selector can be used as a function which takes the full structure and returns the specified field
22:41:11 <c_wraith> So you have unContext :: Context a -> (String -> [String] -> Item a -> Compiler ContextField)
22:41:21 <omentic> hm. i guess i'm confused on what constructing and destructing this newtype would look like
22:42:07 <c_wraith> The reverse is the constructor, which is also a function - Context :: (String -> [String] -> Item a -> Compiler ContextField) -> Context a
22:42:18 × target_i quits (~target_i@user/target-i/x-6023099) (Quit: leaving)
22:42:36 <omentic> ok, so the constructor is implicit from the type of the unContext field?
22:42:47 <omentic> then does that mean you can't have multiple fields in a record in a newtype?
22:43:05 <c_wraith> a newtype is a zero-cost wrapper around another type, so it can only have a single field
22:43:14 <omentic> ohh ok
22:43:16 <c_wraith> a regular record is a data declaration, and can have many fields
22:44:10 <omentic> ah. ok this clears up some confusion. coming from rust that is the case too but there isn't also a separate newtype keyword
22:44:21 <omentic> so just the single-field-record structure implicitly functions like a newtype
22:45:20 <omentic> how do newtypes interact with things that are not single-field-records?
22:45:48 <c_wraith> Well, you can use the non-record syntax. But it's an error to declare a newtype with any number of fields than exactly one
22:47:09 <c_wraith> thanks to Haskell having non-strict semantics, a one-field data type has slightly different behavior than a newtype. So it has a separate keyword for the special case.
22:48:31 <omentic> ok so is newtype Foo = Foo X (about) the same thing as newtype Foo = Foo {x::X}?
22:48:43 <c_wraith> yes
22:49:05 <c_wraith> it doesn't declare the field selector, but it's otherwise identical
22:51:38 <omentic> how then do you destructure a newtype?
22:51:53 <omentic> do you have to worry about the field selector or can you do so the same way as raw data
22:52:25 <c_wraith> you can pattern match no matter how it's declared, or use the field selector if it exists
22:52:36 <c_wraith> Whatever is more convenient for the code you're writing
22:55:11 <omentic> so i guess, what would matching on that newtype Context a = Context (String -> [String] -> Item a -> Compiler ContextField) look like?
22:55:19 <omentic> (i am entirely new to haskell)
22:56:10 <omentic> b/c Context a is like... func Context<A>(String, Vec<String>, Item<A>) -> Compiler<ContextField> in rust syntax right
22:56:25 <c_wraith> Ah. Some of this might be better addressed by going through an intro text, then. But in general, you can pattern match in a case expression or in the LHS of a declaration.
22:56:58 <c_wraith> as an expression, case c of (Context f) -> <some code using f>
22:57:22 <c_wraith> Or in the LHS of a function definition, you'd have something like foo (Context f) = <some code using f>
23:00:00 <omentic> so something like contextToString (Context (foo -> bar -> Item a -> baz)) = ...?
23:00:13 <omentic> (this doesn't work though & i get a warning about ViewPatterns)
23:00:36 <c_wraith> Oh, yeah. functions don't have patterns - you can't match on them. You can only apply them.
23:00:54 <omentic> okok
23:00:56 <c_wraith> So you have to just match on the function as a single name, then you can call that function as desired
23:01:50 <omentic> interesting. i'm now very confused on *why* this is a function b/c i thought it was supposed to be something of a key-value store
23:02:16 <c_wraith> With names like Item and Compiler - is this Hakyll code?
23:02:27 <omentic> oh yeah
23:03:01 <omentic> idk when you jumped in the channel but the background is i'm trying to print debug hakyll so i can figure out what is going on
23:03:25 <omentic> but Context doesn't implement Show, so i need to implement some Context a -> String function so i can use it with trace
23:03:26 <c_wraith> hakyll isn't very friendly towards that. Lots of functions in its internal representations
23:03:41 <omentic> interesting
23:03:50 peterbecich joins (~Thunderbi@syn-047-229-123-186.res.spectrum.com)
23:04:33 <c_wraith> In some sense, a function can act as a lookup in a key-value store. But I don't know if it's doing that for this.
23:05:12 <c_wraith> I honestly try to ignore Hakyll's internals.
23:05:51 × machinedgod quits (~machinedg@d173-183-246-216.abhsia.telus.net) (Ping timeout: 276 seconds)
23:06:11 <omentic> yeah it's basically like. the default hakyll setup does almost everything i want it to. but i want to dynamically dispatch templates based on metadata jekyll-style, ex. having ---\n layout: post\n --- in yaml headers of files
23:06:23 <dibblego> when using ghc -e, how might I reference an installed module?
23:07:07 <omentic> this involves writing a single loadLayoutTemplate :: Context a -> Item a -> Compiler (Item String) function, but it also means i have to understand both hakyll (where is metadata is) and haskell (how to write functions) a little more than i currently do
23:08:14 <dibblego> omentic: took me a while to get my head around hakyll as well. I have an example if it helps.
23:09:08 <omentic> dibblego: i'll defo take an example, most of what i've learned abt it so far has been from reading other ppl's code
23:09:31 <omentic> haven't found someone doing specifically-what-i-want wrt. the jekyll style template thing unfortunately
23:09:32 <dibblego> omentic: https://gitlab.com/system-f/systemf.com.au/ produces this: https://www.systemf.com.au/
23:13:28 gehmehgeh is now known as gmg
23:17:19 × gmg quits (~user@user/gehmehgeh) (Remote host closed the connection)
23:18:04 gmg joins (~user@user/gehmehgeh)
23:22:26 <omentic> dibblego: could you explain this line? https://gitlab.com/system-f/systemf.com.au/-/blob/master/hs/System/F/Rules.hs?ref_type=heads#L65
23:23:00 <omentic> s/line/section ig
23:24:02 <dibblego> that's matching basically everything under the "p" directory and applying templates
23:24:10 <omentic> oh, ok nvm i understand what it's doing now
23:24:29 <omentic> yeah i forgot hakyll like. doesn't explicitly pass around the pages
23:24:34 <dibblego> the "ersa-current" and "charts-current" thing is because of having to produce a link to an external document where that link keeps changing
23:24:58 <omentic> this is helpful though esp for what the Context actually looks like
23:26:21 <omentic> hmmmm maybe Context does not have what i need it to have in there then... i wish i could print it out directly
23:29:52 <omentic> dibblego: do you understand what metadataField, like, is? i'm really hoping it's the metadata from the Pandoc YAML stuff but idk how to find this out
23:34:55 × lain` quits (lain`@user/lain/x-9874679) (Remote host closed the connection)
23:35:50 × Midjak quits (~MarciZ@82.66.147.146) (Quit: This computer has gone to sleep)
23:39:46 lain` joins (lain`@user/lain/x-9874679)
23:40:08 × lain` quits (lain`@user/lain/x-9874679) (Remote host closed the connection)
23:42:45 × Square2 quits (~Square@user/square) (Ping timeout: 248 seconds)
23:43:08 lain` joins (lain`@user/lain/x-9874679)
23:43:40 × ddellacosta quits (~ddellacos@ool-44c73d29.dyn.optonline.net) (Ping timeout: 260 seconds)
23:46:27 × CiaoSen quits (~Jura@2a05:5800:25c:2700:e6b9:7aff:fe80:3d03) (Ping timeout: 252 seconds)
23:46:49 <dibblego> omentic: vaguely, I haven't read the backlog... what are you tryna do?
23:47:18 <dibblego> on a related note, any pandoc experts? https://gist.github.com/tonymorris/c2fd03e175e8da5493f1b4dbec29508c
23:48:07 <omentic> dibblego: basically, i'm not sure what "metadata" refers to
23:48:15 <omentic> i really wish pandoc had like single-line documentation
23:48:38 <omentic> there's also this getMetadataField thing but idk if it is the YAML metadata at the top of items or what
23:49:16 <dibblego> omentic: I found it helped to have it all loaded in a REPL, and to carefully watch the types change as I put it together. I generally forget the details immediately after I get it type-checking and working :)
23:49:23 <omentic> haha
23:49:49 <omentic> oh wait maybe i can print debug this
23:50:52 ddellacosta joins (~ddellacos@ool-44c73d29.dyn.optonline.net)
23:51:27 <omentic> argh item is implicit b/c of hakyll's weird macro dsl. how do i grab this
23:51:44 <c_wraith> the way Hakyll uses Item is mostly a design error anyway
23:51:45 <haskellbridge> <thirdofmay18081814goya> been on twitter since i started following ml researchers
23:51:49 <haskellbridge> <thirdofmay18081814goya> any haskellers worth followingf/
23:51:53 <haskellbridge> <thirdofmay18081814goya> * following?
23:56:15 <dibblego> I agree with design error in hakyll, there are lots imo
23:56:55 <omentic> ok i am hitting a weird error
23:57:19 <omentic> Ambiguous type variable ‘m0’ arising from a use of ‘getMetadataField’ prevents the constraint ‘(MonadMetadata m0)’ from being solved.
23:58:21 <omentic> where abouts should i annotate something to fix this? it is arising from the following line: trace (show (getMetadataField (fromFilePath "about.html"))) ...
23:59:05 <omentic> actually, hm. i should eat and then figure this out it is probably straightforward
23:59:26 <omentic> ty all for all the help today
23:59:31 × omentic quits (~apropos@104.193.135.206) (Quit: leaving)
23:59:34 aaronv joins (~aaronv@user/aaronv)

All times are in UTC on 2024-07-21.