Logs: liberachat/#haskell
| 2021-07-26 12:55:45 | <arkanoid> | I'm studying an introduction to algebraic data types. I've a question: what's the point of writing the last line like that instead of just "emptyBoard = TicTacToe2 Nothing"? https://termbin.com/3os5 |
| 2021-07-26 12:56:24 | <Taneb> | arkanoid: the advantage is that it typechecks |
| 2021-07-26 12:56:37 | → | Topsi joins (~Tobias@dyndsl-037-138-065-137.ewe-ip-backbone.de) |
| 2021-07-26 12:56:44 | <Taneb> | "const $ const Nothing" is of type a -> b -> Maybe a (here, Three -> Three -> Maybe Bool) |
| 2021-07-26 12:56:53 | <Taneb> | Whereas "Nothing" is just of type Maybe a |
| 2021-07-26 12:57:12 | <Taneb> | That first one should end with Maybe c, not Maybe a, sorry |
| 2021-07-26 12:58:37 | × | peterhil quits (~peterhil@mobile-access-5d6af6-209.dhcp.inet.fi) (Ping timeout: 265 seconds) |
| 2021-07-26 12:58:59 | × | gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving) |
| 2021-07-26 12:59:10 | → | gehmehgeh joins (~user@user/gehmehgeh) |
| 2021-07-26 12:59:19 | → | jolly joins (~jolly@208.180.97.158) |
| 2021-07-26 12:59:40 | <arkanoid> | thanks! |
| 2021-07-26 12:59:43 | <arkanoid> | makes sense |
| 2021-07-26 13:00:27 | × | jippiedoe quits (~david@2a02-a44c-e14e-1-71e9-bb56-c41b-9e9d.fixed6.kpn.net) (Ping timeout: 268 seconds) |
| 2021-07-26 13:00:32 | × | derelict quits (~derelict@user/derelict) (Ping timeout: 245 seconds) |
| 2021-07-26 13:00:42 | × | dunkeln quits (~dunkeln@94.129.69.87) (Ping timeout: 240 seconds) |
| 2021-07-26 13:01:04 | → | jippiedoe joins (~david@77-171-152-62.fixed.kpn.net) |
| 2021-07-26 13:01:08 | → | alx741 joins (~alx741@186.178.108.3) |
| 2021-07-26 13:03:00 | × | jneira quits (~jneira@212.8.115.226) (Quit: Client closed) |
| 2021-07-26 13:03:44 | × | Obo quits (~roberto@70.pool90-171-81.dynamic.orange.es) (Ping timeout: 256 seconds) |
| 2021-07-26 13:04:04 | → | peterhil joins (~peterhil@mobile-access-5d6af6-209.dhcp.inet.fi) |
| 2021-07-26 13:07:25 | <arkanoid> | is there any difference in writing "data TicTacToe2 a = TicTacToe2 { board :: Three -> Three -> a}" and "data TicTacToe2 a = TicTacToe Three -> Three -> a" apart the generated "board" get function? |
| 2021-07-26 13:07:50 | <arkanoid> | forget a "2" on second TicTacToe |
| 2021-07-26 13:09:14 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-26 13:09:33 | <Taneb> | There's a few more minor differences, you get the record syntax with the first one, so you could write "TicTacToe2 { board = const $ const Nothing }" for example |
| 2021-07-26 13:10:06 | × | Kaipi quits (~Kaiepi@nwcsnbsc03w-47-54-173-93.dhcp-dynamic.fibreop.nb.bellaliant.net) (Ping timeout: 250 seconds) |
| 2021-07-26 13:10:07 | × | anandprabhu quits (~anandprab@94.202.243.198) (Quit: Konversation terminated!) |
| 2021-07-26 13:10:19 | → | Kaiepi joins (~Kaiepi@nwcsnbsc03w-47-54-173-93.dhcp-dynamic.fibreop.nb.bellaliant.net) |
| 2021-07-26 13:10:57 | → | LukeHoersten joins (~LukeHoers@user/lukehoersten) |
| 2021-07-26 13:11:24 | → | curiousgay joins (~curiousga@77-120-186-48.kha.volia.net) |
| 2021-07-26 13:11:41 | <arkanoid> | thanks |
| 2021-07-26 13:12:53 | × | hendursa1 quits (~weechat@user/hendursaga) (Quit: hendursa1) |
| 2021-07-26 13:13:24 | → | hendursaga joins (~weechat@user/hendursaga) |
| 2021-07-26 13:14:05 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 265 seconds) |
| 2021-07-26 13:16:21 | → | slowButPresent joins (~slowButPr@user/slowbutpresent) |
| 2021-07-26 13:16:30 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 265 seconds) |
| 2021-07-26 13:17:25 | → | derelict joins (~derelict@user/derelict) |
| 2021-07-26 13:18:12 | → | Obo joins (~roberto@70.pool90-171-81.dynamic.orange.es) |
| 2021-07-26 13:18:48 | <Cajun> | im reading the same book atm, is there a benefit to record syntax? when i was learning haskell from Programming in Haskell, record syntax was never mentioned, so it always seems unnatural. is it just cleaner? |
| 2021-07-26 13:21:52 | → | Bayes joins (~Bayes@ics177-97.icsincorporated.com) |
| 2021-07-26 13:21:58 | × | chris_ quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2021-07-26 13:22:08 | × | Bayes quits (~Bayes@ics177-97.icsincorporated.com) (Changing host) |
| 2021-07-26 13:22:08 | → | Bayes joins (~Bayes@user/bayes) |
| 2021-07-26 13:23:18 | <Cajun> | is it just more for your money (you get record syntax), or does it have more of a benefit? |
| 2021-07-26 13:23:34 | <juri_> | I actually find it dirtier, as it creates accessor functions by default, which can be.. poorly named. |
| 2021-07-26 13:23:54 | <jippiedoe> | It's a way to name fields, so if you ever find yourself with a datatype `Data Foo = Foo Bool Bool Bool` it might be better to use record syntax to name all of those. Ofcourse, you can often sidestep the issue with better datatype design! |
| 2021-07-26 13:23:57 | <juri_> | in a project i inherited, i had an accessor function for 'x' and 'y'. bad. |
| 2021-07-26 13:24:55 | × | gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving) |
| 2021-07-26 13:25:24 | <arkanoid> | does it make any sense to use record syntax for a data type with just 1 type, like the aforementioned example? |
| 2021-07-26 13:27:38 | × | jiribenes quits (~jiribenes@rosa.jiribenes.com) (Ping timeout: 255 seconds) |
| 2021-07-26 13:29:17 | × | fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 245 seconds) |
| 2021-07-26 13:30:03 | → | fossdd joins (~fossdd@sourcehut/user/fossdd) |
| 2021-07-26 13:31:04 | <arthurxavierx> | At work we've tried a lot of stuff and settled down on using DuplicateRecordFields, RecordWildCards and generic-lens (but HasField from GHC.Records works just fine as well). We don't prefix record accessors and only use RecordWildCards when constructing or destructing records in a sufficiently narrow scope. To access fields in other contexts we use `getField @"fieldName"`. This approach has been working very well IMO. |
| 2021-07-26 13:31:51 | <arthurxavierx> | although I'd find it easier on the eye if we used OverloadedLabels to have it look like IHP's `get #fieldName` |
| 2021-07-26 13:33:03 | → | jao joins (~jao@cpc103048-sgyl39-2-0-cust502.18-2.cable.virginm.net) |
| 2021-07-26 13:33:51 | → | jiribenes joins (~jiribenes@rosa.jiribenes.com) |
| 2021-07-26 13:34:46 | <jippiedoe> | arkanoid: For newtypes, it's a common style to write `newtype Foo = Foo { runFoo :: _ }`, but it only really saves 1 line of defining runFoo yourself. Small benefit is that (I think) you import `runFoo` for free with `Foo(..)` |
| 2021-07-26 13:36:23 | × | curiousgay quits (~curiousga@77-120-186-48.kha.volia.net) (Ping timeout: 252 seconds) |
| 2021-07-26 13:36:59 | × | andreabedini quits (~andreabed@ec2-3-25-98-120.ap-southeast-2.compute.amazonaws.com) (Quit: The Lounge - https://thelounge.chat) |
| 2021-07-26 13:37:45 | → | andreabedini joins (~andreabed@ec2-3-25-98-120.ap-southeast-2.compute.amazonaws.com) |
| 2021-07-26 13:39:54 | <yushyin> | juri_: NoFieldSelectors to the rescue https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/field_selectors.html#extension-FieldSelectors |
| 2021-07-26 13:41:14 | × | LukeHoersten quits (~LukeHoers@user/lukehoersten) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-07-26 13:42:41 | → | chris_ joins (~chris@81.96.113.213) |
| 2021-07-26 13:45:59 | <arthurxavierx> | yushyin: do you know if NoFieldSelectors have any weird interaction with RecordWildCards? |
| 2021-07-26 13:49:51 | <yushyin> | arthurxavierx: i don't know for sure, but it should work just fine since the fields are still available. (it's only the selector functions that are no longer generated) |
| 2021-07-26 13:50:12 | <arthurxavierx> | hm that makes sense. thanks! |
| 2021-07-26 13:50:40 | → | zebrag joins (~chris@user/zebrag) |
| 2021-07-26 13:56:57 | <arkanoid> | thanks |
| 2021-07-26 13:58:02 | × | jippiedoe quits (~david@77-171-152-62.fixed.kpn.net) (Ping timeout: 245 seconds) |
| 2021-07-26 13:58:49 | <nshepperd2> | iirc the selector functions are actually generated, they're just made inaccessible in the top level namespace |
| 2021-07-26 13:58:50 | × | ystael quits (~ystael@user/ystael) (Quit: Lost terminal) |
| 2021-07-26 14:00:22 | × | fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 272 seconds) |
| 2021-07-26 14:01:26 | → | fossdd joins (~fossdd@sourcehut/user/fossdd) |
| 2021-07-26 14:01:40 | → | ystael joins (~ystael@user/ystael) |
| 2021-07-26 14:03:13 | × | derelict quits (~derelict@user/derelict) (Quit: WeeChat 3.2) |
| 2021-07-26 14:05:48 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-07-26 14:06:55 | <yushyin> | even that might be the case, yes, i should not have assumed this without knowing the implementation |
| 2021-07-26 14:07:46 | → | Sgeo joins (~Sgeo@user/sgeo) |
| 2021-07-26 14:08:28 | → | LukeHoersten joins (~LukeHoers@user/lukehoersten) |
| 2021-07-26 14:09:29 | × | Vajb quits (~Vajb@hag-jnsbng11-58c3a1-224.dhcp.inet.fi) (Read error: Connection reset by peer) |
| 2021-07-26 14:10:07 | → | Vajb joins (~Vajb@2001:999:62:1d53:26b1:6c9b:c1ed:9c01) |
| 2021-07-26 14:10:25 | → | enoq joins (~enoq@194-208-179-35.lampert.tv) |
| 2021-07-26 14:10:31 | → | jippiedoe joins (~david@77-171-152-62.fixed.kpn.net) |
| 2021-07-26 14:10:32 | × | acidjnk_new quits (~acidjnk@p200300d0c72b9530a5bcc5cf9bf6f5b6.dip0.t-ipconnect.de) (Ping timeout: 245 seconds) |
| 2021-07-26 14:11:08 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 258 seconds) |
| 2021-07-26 14:13:11 | × | chris_ quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2021-07-26 14:13:16 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-07-26 14:16:55 | × | zaquest quits (~notzaques@5.128.210.178) (Remote host closed the connection) |
| 2021-07-26 14:18:03 | → | chris_ joins (~chris@81.96.113.213) |
| 2021-07-26 14:18:24 | × | lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 276 seconds) |
| 2021-07-26 14:18:32 | → | zaquest joins (~notzaques@5.128.210.178) |
| 2021-07-26 14:19:01 | × | jippiedoe quits (~david@77-171-152-62.fixed.kpn.net) (Quit: Leaving) |
| 2021-07-26 14:19:05 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2021-07-26 14:19:10 | → | neceve joins (~quassel@2a02:c7f:607e:d600:f762:20dd:304e:4b1f) |
| 2021-07-26 14:22:29 | × | chris_ quits (~chris@81.96.113.213) (Ping timeout: 252 seconds) |
| 2021-07-26 14:22:57 | → | chris_ joins (~chris@81.96.113.213) |
| 2021-07-26 14:23:52 | × | andreabedini quits (~andreabed@ec2-3-25-98-120.ap-southeast-2.compute.amazonaws.com) (Quit: The Lounge - https://thelounge.chat) |
| 2021-07-26 14:24:41 | × | xff0x quits (~xff0x@2001:1a81:523c:b300:f2c1:fc0d:e213:d303) (Ping timeout: 252 seconds) |
| 2021-07-26 14:25:21 | → | xff0x joins (~xff0x@2001:1a81:523c:b300:334f:584b:1868:61b3) |
| 2021-07-26 14:27:52 | <raehik1> | Is it possible to use Happy in a context-sensitive manner, eg have two rules where the expansions are the same(/similar), but the correct one can be selected by checking some state somewhere? |
| 2021-07-26 14:28:36 | <raehik1> | Not a language design question, it's a pre-existing language that's known for being horrible for parsing |
All times are in UTC.