Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→
Page 1 .. 431 432 433 434 435 436 437 438 439 440 441 .. 17998
1,799,724 events total
2021-06-13 14:07:11 dustingetz joins (~textual@pool-173-49-123-198.phlapa.fios.verizon.net)
2021-06-13 14:11:01 tromp joins (~textual@dhcp-077-249-230-040.chello.nl)
2021-06-13 14:12:26 × mikoto-chan quits (~mikoto-ch@ip-213-49-189-31.dsl.scarlet.be) (Read error: Connection reset by peer)
2021-06-13 14:14:09 Solarion_ is now known as Solarion
2021-06-13 14:14:23 iridescent joins (~iridescen@41337027.cst.lightpath.net)
2021-06-13 14:14:26 <iridescent> has anyone seen this? https://bitemyapp.com/blog/grokking-sums-and-constructors/
2021-06-13 14:14:40 <iridescent> i'm having trouble understanding the point of all of this
2021-06-13 14:14:56 <iridescent> they're wrapping things with value constructors, but can't you just do the exact same thing without them?
2021-06-13 14:15:07 <iridescent> definitely missing something, but not sure what it is
2021-06-13 14:20:03 × xkuru quits (~xkuru@user/xkuru) (Remote host closed the connection)
2021-06-13 14:20:40 mikoto-chan joins (~mikoto-ch@ip-213-49-189-31.dsl.scarlet.be)
2021-06-13 14:23:10 × thelounge92 quits (~thelounge@cpe-23-240-28-18.socal.res.rr.com) (Ping timeout: 272 seconds)
2021-06-13 14:24:30 <nitrix> The article seems to try to introduce some core concepts of the language; it's not really trying to achieve anything special.
2021-06-13 14:25:19 <nitrix> What is the wrapping you think of and what confuses you?
2021-06-13 14:26:43 <iridescent> oh hm
2021-06-13 14:26:46 <iridescent> just like
2021-06-13 14:26:53 <iridescent> if you don't actually need names for fruits
2021-06-13 14:27:08 <iridescent> why would you want to have data Apple and data Orange over data Fruit = Apple | Orange
2021-06-13 14:27:57 <nitrix> Right. I see the confusion now.
2021-06-13 14:28:05 × da39a3ee5e6b4b0d quits (~textual@2403:6200:8876:2955:1da4:ecb3:1c84:7a5a) (Quit: Textual IRC Client: www.textualapp.com)
2021-06-13 14:28:52 <janus> if you have them separate, you can use them to parametrize other types
2021-06-13 14:29:26 <janus> essentially, do you want the distinction at runtime or compile time?
2021-06-13 14:29:30 oxide joins (~lambda@user/oxide)
2021-06-13 14:29:31 <nitrix> iridescent, If you allow me, I think I have an example that makes more sense then theirs to build your intuition.
2021-06-13 14:29:39 <iridescent> sure why not :)
2021-06-13 14:29:40 adanwan_ joins (~adanwan@gateway/tor-sasl/adanwan)
2021-06-13 14:29:53 <iridescent> also how is this different from dependent types?
2021-06-13 14:30:03 <iridescent> or is it just a specific instance of that
2021-06-13 14:30:04 × adanwan quits (~adanwan@gateway/tor-sasl/adanwan) (Ping timeout: 252 seconds)
2021-06-13 14:30:25 <nitrix> iridescent, Haskell has two data types, you can have either product types or sum types. I can explain why they're named this way later, but they conceptually are very close to a struct and a tagged union if you're familiar with those.
2021-06-13 14:30:26 jaevanko joins (~jaevanko@2600:1700:1330:2bef:d2ba:7480:75b7:9b34)
2021-06-13 14:30:40 Nixkernal joins (~Nixkernal@2a02:1205:34ed:fa00:a5f7:ad7:30d5:9688)
2021-06-13 14:30:40 × pe200012_ quits (~pe200012@58.248.179.150) (Remote host closed the connection)
2021-06-13 14:30:44 <iridescent> yeah i get the concept of sum and product types
2021-06-13 14:31:07 pe200012_ joins (~pe200012@58.248.179.150)
2021-06-13 14:31:18 <nitrix> iridescent, So, starting with the product types, a couple examples would be: data Circle = MkCircle Float and data Rectangle = MkRectangle Int Int
2021-06-13 14:31:49 <iridescent> yep
2021-06-13 14:32:14 <nitrix> Here, `Circle` and `Rectangle` are the type names, while `MkCircle` and `MkRectangle` are the constructors. They are functions that will accept either a `Float` or two `Int` to eventually create a Circle or a Rectangle.
2021-06-13 14:32:37 hemlock joins (~hemlock@ip72-203-188-10.tu.ok.cox.net)
2021-06-13 14:32:57 jmcarthur joins (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net)
2021-06-13 14:33:19 <iridescent> got it
2021-06-13 14:33:40 <nitrix> Similarly, you can also have sum types. The syntax is a bit different, the different possible options are separated by a | character. An example would be: data Weekday = Monday | Tuesday | Wednesday | Thirday | Friday.
2021-06-13 14:34:30 <nitrix> Here, `Monday` is also a constructor, but it doesn't take any argument. Using it immediately creates a `Weekday`.
2021-06-13 14:35:49 <nitrix> Haskell is said to have algebraic data types, and so, to showcase a bit that "algebra" (which I think is what the article was trying to do), you would combine sum types with product types into a new type.
2021-06-13 14:35:51 × ubikium quits (~ubikium@2400:2200:3f7:8d39:b162:d489:71fa:a323) (Read error: Connection reset by peer)
2021-06-13 14:37:13 <nitrix> iridescent, Something like data Shape = TheCircle Circle | TheSquare Square, where `Shape` can be constructed with two different ways, either TheCircle or TheSquare, which accepts a Circle and a Square respectively.
2021-06-13 14:37:27 ubikium joins (~ubikium@113x43x248x70.ap113.ftth.arteria-hikari.net)
2021-06-13 14:37:42 bmo joins (~bmo@185.254.75.34)
2021-06-13 14:38:09 shapr joins (~user@pool-108-28-144-11.washdc.fios.verizon.net)
2021-06-13 14:38:40 <nitrix> Does that make sense or I lost you :P ?
2021-06-13 14:40:47 × hemlock quits (~hemlock@ip72-203-188-10.tu.ok.cox.net) (Quit: Quit)
2021-06-13 14:41:44 bleloch_ joins (bleloch@gateway/vpn/protonvpn/bleloch)
2021-06-13 14:41:50 hemlock joins (~hemlock@ip72-203-188-10.tu.ok.cox.net)
2021-06-13 14:42:14 <bmo> What are currently the "best" frameworks (non-static) to write web-applications? It's been a while I used yesod before and servant as well but I wasn't necessarily too convinced of either.
2021-06-13 14:42:36 <bmo> yesod felt like a very over-kill solution and pretty heavy-weight.
2021-06-13 14:43:24 <bmo> servant was nice and I liked it quite a bit sometimes, however I recall having to write my own authentication layer which felt wrong
2021-06-13 14:43:40 <bmo> What do people use nowadays?
2021-06-13 14:44:39 peterhil joins (~peterhil@dsl-hkibng32-54f849-252.dhcp.inet.fi)
2021-06-13 14:45:20 × dustingetz quits (~textual@pool-173-49-123-198.phlapa.fios.verizon.net) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-06-13 14:46:31 pavonia joins (~user@user/siracusa)
2021-06-13 14:47:41 derelict joins (~derelict@user/derelict)
2021-06-13 14:48:04 <janus> bmo: i am not sure people that like advanced typing stuff ever stopped using servant
2021-06-13 14:48:15 Obo joins (~roberto@h-46-59-103-134.A498.priv.bahnhof.se)
2021-06-13 14:48:37 × gedda quits (~gedda@user/gedda) (Quit: Lost terminal)
2021-06-13 14:49:26 Bartosz joins (~textual@24.35.90.211)
2021-06-13 14:53:41 slowButPresent joins (~slowButPr@user/slowbutpresent)
2021-06-13 14:56:37 × Obo quits (~roberto@h-46-59-103-134.A498.priv.bahnhof.se) (Quit: WeeChat 2.8)
2021-06-13 15:01:51 × jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
2021-06-13 15:03:04 × gentauro quits (~gentauro@user/gentauro) (Read error: Connection reset by peer)
2021-06-13 15:03:25 wallymathieu joins (~wallymath@81-234-151-21-no94.tbcn.telia.com)
2021-06-13 15:07:29 × oxide quits (~lambda@user/oxide) (Ping timeout: 272 seconds)
2021-06-13 15:07:32 <iridescent> nitrix: think it makes sense, so basically your last example is like <constructor 1 which can take in a lot of arguments> OR <constructor 2 which can take a lot of argumnets>, and the lots of arguments is the product type
2021-06-13 15:08:37 gentauro joins (~gentauro@user/gentauro)
2021-06-13 15:09:24 jmcarthur joins (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net)
2021-06-13 15:09:33 rk04 joins (~rk04@user/rajk)
2021-06-13 15:09:40 × jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Client Quit)
2021-06-13 15:11:11 jmcarthur joins (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net)
2021-06-13 15:11:29 × jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Client Quit)
2021-06-13 15:11:33 <nitrix> iridescent, The sum type gives you a choice between multiple values to construct the type. data Foo = A | B | C, there are 3 possible values of type Foo, the A, B and C.
2021-06-13 15:12:53 <nitrix> iridescent, Product types combines existing types, so data Bar = F Foo Foo, would construct a Bar with two Foo, that's 9 possible values, F A A, F A B, F A C, F B A, F B B, F B C, F C A, F C B, F C C.
2021-06-13 15:13:34 <nitrix> I guess that's a little hint as to why they're called sum versus product.
2021-06-13 15:14:09 <nitrix> Sorry, 6 values x]
2021-06-13 15:14:14 <nitrix> Two Foo with 3 values each, 2 * 3 = 6.
2021-06-13 15:16:28 <nitrix> As for the sum, if I did data Bar = F1 Foo | F2 Foo, the possible values would be F1 A, F1 B, F1 C, F2 A, F2 B, F2 C, aka sum type, 3 + 3 = 6.
2021-06-13 15:17:00 <nitrix> I chose a bad example that both arrives to 6, but you can see how the arithmetic is different :P
2021-06-13 15:17:08 Obo joins (~roberto@h-46-59-103-134.A498.priv.bahnhof.se)
2021-06-13 15:18:04 <iridescent> yeah
2021-06-13 15:18:05 <iridescent> i see
2021-06-13 15:19:15 dustingetz joins (~textual@pool-173-49-123-198.phlapa.fios.verizon.net)
2021-06-13 15:19:40 dunkeln joins (~dunkeln@94.129.65.28)
2021-06-13 15:22:49 bhrgunatha joins (~bhrgunath@2001-b011-8011-27f4-086a-6ad6-9ae6-0f90.dynamic-ip6.hinet.net)
2021-06-13 15:23:09 fendor_ is now known as fendor
2021-06-13 15:24:22 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:4587:6292:4bfd:4d24)
2021-06-13 15:24:34 <pavonia> nitrix: 9 values was correct, it's Foo x Foo
2021-06-13 15:25:48 <nitrix> Oh, thank god. I was wondering if I was losing it while explaining that, haha.
2021-06-13 15:25:48 × tv quits (~tv@user/tv) (Read error: Connection reset by peer)
2021-06-13 15:26:44 <nitrix> So yeah, 3x3=9 vs 3+3=6, as an example of why the product `F Foo Foo` differs from the sum `F1 Foo | F2 Foo`.
2021-06-13 15:26:53 <iridescent> got it
2021-06-13 15:27:00 <iridescent> i guess product is like taking combinations
2021-06-13 15:27:04 <nitrix> Yep.

All times are in UTC.