Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-23 11:06:54 × idhugo_ quits (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net) (Ping timeout: 252 seconds)
2021-04-23 11:07:30 nicholasbulka joins (~nicholasb@2601:900:4301:da0:5440:6bb8:f181:7832)
2021-04-23 11:07:46 idhugo_ joins (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net)
2021-04-23 11:07:53 <timCF> merijn: <|> feels actually opposite to monoid :) But type signatures of <|> and <> are looking similar for sure
2021-04-23 11:08:13 jumper149 joins (~jumper149@80.240.31.34)
2021-04-23 11:08:40 <merijn> timCF: That laws are the same too :p
2021-04-23 11:08:57 <merijn> left-associative operator, identity element
2021-04-23 11:09:55 × sQVe quits (~sQVe@unaffiliated/sqve) (Quit: Bye!)
2021-04-23 11:10:25 × idhugo__ quits (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net) (Ping timeout: 252 seconds)
2021-04-23 11:10:36 idhugo joins (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net)
2021-04-23 11:11:08 × refusenick quits (~user@2601:644:8502:d700::8cfb) (Ping timeout: 258 seconds)
2021-04-23 11:12:13 × nicholasbulka quits (~nicholasb@2601:900:4301:da0:5440:6bb8:f181:7832) (Ping timeout: 276 seconds)
2021-04-23 11:12:38 × nut quits (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Ping timeout: 246 seconds)
2021-04-23 11:13:09 × idhugo_ quits (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net) (Ping timeout: 252 seconds)
2021-04-23 11:13:14 <timCF> Btw, is computation `a <|> b <|> c` lazy in case where type of every expression is `ExceptT e m a` where `m` is some side-effect IO-like monad. In case where `a` returns Right, will be side-effects of `b` and `c` executed?
2021-04-23 11:14:59 Guest_92 joins (7a3b26e8@122-59-38-232-adsl.sparkbb.co.nz)
2021-04-23 11:19:31 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-04-23 11:19:41 heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-04-23 11:23:11 geowiesnot joins (~user@87-89-181-157.abo.bbox.fr)
2021-04-23 11:23:50 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 246 seconds)
2021-04-23 11:24:09 × heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 252 seconds)
2021-04-23 11:25:10 nut joins (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr)
2021-04-23 11:25:50 machinedgod joins (~machinedg@135-23-192-217.cpe.pppoe.ca)
2021-04-23 11:26:52 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-04-23 11:28:53 vilpan parts (~0@212.117.1.172) ()
2021-04-23 11:31:09 × Unhammer quits (~Unhammer@gateway/tor-sasl/unhammer) (Ping timeout: 240 seconds)
2021-04-23 11:33:53 × quinn quits (~quinn@c-73-223-224-163.hsd1.ca.comcast.net) (Quit: ZNC 1.8.1 - https://znc.in)
2021-04-23 11:34:33 × LKoen quits (~LKoen@11.160.9.109.rev.sfr.net) (Remote host closed the connection)
2021-04-23 11:34:59 akulkarni joins (~user@37.164.172.175)
2021-04-23 11:35:09 <akulkarni> I have the following function:
2021-04-23 11:35:13 <akulkarni> area::[Integer] -> [Integer] -> Integer -> Double
2021-04-23 11:35:13 <akulkarni> area w x y = sum $ zipWith (*) (zipWith (/) (map fromInteger w) [l+1 | l <- x]) [y^(k+1) | k <- x]
2021-04-23 11:35:44 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 246 seconds)
2021-04-23 11:36:27 <akulkarni> why does it give an error saying "Couldn't match expected type ‘Double’ with actual type ‘Integer’"
2021-04-23 11:37:22 × sayola1 quits (~vekto@dslb-002-201-085-157.002.201.pools.vodafone-ip.de) (Read error: Connection reset by peer)
2021-04-23 11:38:50 <merijn> [l+1 | l <- x] is [Integer]
2021-04-23 11:38:59 <merijn> but zipWith (/) expects a Double
2021-04-23 11:39:54 sayola joins (~vekto@dslb-002-201-085-157.002.201.pools.vodafone-ip.de)
2021-04-23 11:41:16 × geowiesnot quits (~user@87-89-181-157.abo.bbox.fr) (Ping timeout: 268 seconds)
2021-04-23 11:42:05 <xsperry> > zipWith ((/) `on` fromInteger) [10,20,30] (repeat 5)
2021-04-23 11:42:08 <lambdabot> [2.0,4.0,6.0]
2021-04-23 11:44:54 Unhammer joins (~Unhammer@gateway/tor-sasl/unhammer)
2021-04-23 11:45:50 <akulkarni> oh so the denominator should also be a Double, got it. Thanks @xsperry and @merijn
2021-04-23 11:46:13 <xsperry> yes, see the type
2021-04-23 11:46:16 <xsperry> :t (/)
2021-04-23 11:46:18 <lambdabot> Fractional a => a -> a -> a
2021-04-23 11:46:24 <xsperry> same a
2021-04-23 11:46:52 <akulkarni> indeed
2021-04-23 11:50:01 mason_ joins (~bc8134e3@1582020-static.lxtnkya3.metronetinc.net)
2021-04-23 11:50:07 <mason_> hi. I want to create a Money type, that supports multiple currencies that can be added together. what I'm unsure is how to go about creating a Num etc instance, given that the result may change depending on the used exchange rate
2021-04-23 11:55:06 Merfont joins (~Kaiepi@47.54.252.148)
2021-04-23 11:56:26 × Kaeipi quits (~Kaiepi@47.54.252.148) (Remote host closed the connection)
2021-04-23 11:57:06 invaser joins (~Thunderbi@31.148.23.125)
2021-04-23 11:57:39 × invaser quits (~Thunderbi@31.148.23.125) (Client Quit)
2021-04-23 11:58:17 LKoen joins (~LKoen@11.160.9.109.rev.sfr.net)
2021-04-23 11:58:31 <timCF> mason_: creating your own is exciting for sure, but you might like this one https://ren.zone/articles/safe-money
2021-04-23 11:58:43 <merijn> mason_: Short answer: Don't
2021-04-23 11:59:42 <merijn> It doesn't really make sense, because money isn't a number. $100 divided by 10 makes sense. $100 divided by $10 does not
2021-04-23 11:59:49 <merijn> :t (/)
2021-04-23 11:59:51 <lambdabot> Fractional a => a -> a -> a
2021-04-23 12:00:00 <merijn> Which is what Num/Fractional would incur
2021-04-23 12:00:43 <merijn> Numbers with units don't really behave like numbers and the wisest course of action is to not pretend that they do
2021-04-23 12:01:04 <timCF> actually I think safe-money is providing Num instances, it's wrong in general, just trade off for usability. But in other aspects library is good
2021-04-23 12:01:19 <akulkarni> @xsperry the function you wrote gives the same output even without adding `on` fromInteger
2021-04-23 12:01:19 <lambdabot> Unknown command, try @list
2021-04-23 12:01:52 <akulkarni> @xsperry so I don't get how adding that helps
2021-04-23 12:01:52 <lambdabot> Unknown command, try @list
2021-04-23 12:02:13 <xsperry> akulkarni, because number literals are polymorphic
2021-04-23 12:02:18 <xsperry> > zipWith (/) [10,20,30 :: Integer] (repeat 5)
2021-04-23 12:02:20 <lambdabot> error:
2021-04-23 12:02:20 <lambdabot> • No instance for (Fractional Integer) arising from a use of ‘/’
2021-04-23 12:02:20 <lambdabot> • In the first argument of ‘zipWith’, namely ‘(/)’
2021-04-23 12:02:29 <xsperry> > zipWith ((/) `on` fromInteger) [10,20,30 :: Integer] (repeat 5)
2021-04-23 12:02:32 <lambdabot> [2.0,4.0,6.0]
2021-04-23 12:03:12 <akulkarni> xsperry ok thanks for pointing out the difference
2021-04-23 12:03:42 lemmih joins (~lemmih@2406:3003:2072:44:b750:bcd2:3182:6116)
2021-04-23 12:03:46 invaser joins (~Thunderbi@31.148.23.125)
2021-04-23 12:03:59 codygman__ joins (~user@47.186.207.161)
2021-04-23 12:04:33 <merijn> :t 5
2021-04-23 12:04:35 <lambdabot> Num p => p
2021-04-23 12:04:38 <merijn> > 5 :: Int
2021-04-23 12:04:40 <lambdabot> 5
2021-04-23 12:04:42 <merijn> > 5 :: Double
2021-04-23 12:04:44 <lambdabot> 5.0
2021-04-23 12:05:00 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-23 12:05:11 × ij quits (~ij@NixOS/user/siers) (Ping timeout: 240 seconds)
2021-04-23 12:05:13 <invaser> Hi! Wanted to ask a question relating to HSL in VSCode. Is it possible to disable a codelens (I guess that's what it's called) that adds an explicit import list? It's became quite annoying when import list is large. Here's what I'm talking about: https://i.imgur.com/3BHxPZV.png
2021-04-23 12:06:02 urodna joins (~urodna@unaffiliated/urodna)
2021-04-23 12:06:14 <mason_> so in safe-money, money expressed in one currency is of different type than money expressed in another?
2021-04-23 12:06:34 <timCF> invaser: so it shows what exactly is used from imports?
2021-04-23 12:07:52 <invaser> timCF: Yes, and on click it adds an explicit list of imports to the line
2021-04-23 12:08:22 <timCF> mason_: yes, different currency = different money types. It make sense, because different money types have different fungibility properties - for example bitcoin has the smallest possible unit, but gold does not, you can devide it as much as you want.
2021-04-23 12:08:27 <mason_> I have items with price field, which can be in several different currencies. to support that with safe-money, I would have to create a sum type of different currencies, which doesn't seem ideal. a Money type I imagined would already be a sum type of all supported currencies
2021-04-23 12:09:41 <invaser> Overall, I'm not really sure if I should remove it, ha-ha. I just find it a little bit annoying. But it seems that I've seen somewhere (probably in GHC coding style guide) that you shouldn't really use explicit import list except for when declarations clash with each other. Should I use explicit or implicit generally?
2021-04-23 12:09:58 <timCF> invaser: that's super cool! I want vim plugin which is doing this automatically as well)
2021-04-23 12:12:53 minoru_shiraeesh joins (~shiraeesh@46.34.206.15)
2021-04-23 12:13:07 <merijn> invaser: explicit, imo
2021-04-23 12:13:23 <merijn> invaser: GHC is a bit special in that is only allowed to have a tiny number of dependencies
2021-04-23 12:13:50 <merijn> invaser: Which makes it easy to assume everyone knows most types and where they're from
2021-04-23 12:14:18 Pickchea joins (~private@unaffiliated/pickchea)

All times are in UTC.