Logs: freenode/#haskell
| 2020-10-04 01:01:03 | → | quazimodo joins (~quazimodo@60-240-169-126.static.tpgi.com.au) |
| 2020-10-04 01:01:21 | <quazimodo> | sorry for o/t, is there an ocaml channel on freenode? |
| 2020-10-04 01:02:38 | → | xerox_ joins (~xerox@unaffiliated/xerox) |
| 2020-10-04 01:02:49 | <cohn> | quazimodo: /join #ocaml seems to be an actual OCaml channel |
| 2020-10-04 01:02:54 | × | quazimodo quits (~quazimodo@60-240-169-126.static.tpgi.com.au) (Client Quit) |
| 2020-10-04 01:05:08 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-04 01:07:01 | → | zoom66 joins (44beb1c9@068-190-177-201.res.spectrum.com) |
| 2020-10-04 01:07:38 | → | carlomagno joins (~cararell@inet-hqmc02-o.oracle.com) |
| 2020-10-04 01:08:05 | <zoom66> | Question regarding polymorphic type associated with Num typeclass |
| 2020-10-04 01:08:22 | <zoom66> | Each of the following three funcs simply return the value passed to them: |
| 2020-10-04 01:08:25 | <zoom66> | retNum:: (Num a) => a -> a ; retNum x = x |
| 2020-10-04 01:08:29 | <zoom66> | retInt :: Int -> Int ; retInt x = x |
| 2020-10-04 01:08:33 | <zoom66> | retInteger :: Integer -> Integer ; retInteger x = x |
| 2020-10-04 01:08:38 | <zoom66> | if in GHCI I do retInt (retNum 10000000000000000000), I get an Int out of range warning, which is expected |
| 2020-10-04 01:08:42 | <zoom66> | however, if I do z = retNum 10000000000000000000 |
| 2020-10-04 01:08:50 | <zoom66> | and then retInt z, I get an Int value which has wrapped since 'z' is too large for an Int to hold |
| 2020-10-04 01:09:46 | <zoom66> | retInt z displays -8446744073709551616 |
| 2020-10-04 01:10:16 | <zoom66> | i'm a noob and trying to understand what bounding var checking I should be expecting, if any |
| 2020-10-04 01:10:31 | × | alp quits (~alp@2a01:e0a:58b:4920:d804:7750:2986:4170) (Ping timeout: 272 seconds) |
| 2020-10-04 01:10:58 | <zoom66> | naturally if I do retInteger z, I get the correct value |
| 2020-10-04 01:12:07 | <dolio> | Where are you doing the second thing? |
| 2020-10-04 01:12:16 | <zoom66> | ghci |
| 2020-10-04 01:12:39 | <dolio> | Well, z is probably a polymorphic value. |
| 2020-10-04 01:12:54 | <dolio> | Then retInt is instantiating it to Int. |
| 2020-10-04 01:13:10 | <zoom66> | so is there no type bounds checking for retInt? |
| 2020-10-04 01:13:19 | <dolio> | The warning only happens when you use a literal at a type known to be Int, I think. |
| 2020-10-04 01:13:44 | → | toorevitimirp joins (~tooreviti@117.182.181.38) |
| 2020-10-04 01:14:02 | <zoom66> | it's basically just truncating the value to an Int. is that typical for a polymorphic type of Num typeclass? |
| 2020-10-04 01:14:11 | × | solonarv quits (~solonarv@astrasbourg-653-1-252-112.w92-161.abo.wanadoo.fr) (Ping timeout: 240 seconds) |
| 2020-10-04 01:14:19 | → | vicfred joins (~vicfred@unaffiliated/vicfred) |
| 2020-10-04 01:15:50 | <zoom66> | ok, just tried it in compiled code and the z = retNum 10000000000000000000 generates the -Woverflowed-literals warning |
| 2020-10-04 01:15:53 | <dolio> | Numeric literals just wrap around on the finite integer types in base. |
| 2020-10-04 01:16:12 | <zoom66> | i don't get the warning doing the same statement interactively in ghci |
| 2020-10-04 01:16:17 | <dolio> | Because the `fromInteger` function wraps around. |
| 2020-10-04 01:17:06 | <dolio> | Well, in the compiled code, it will probably be trying to find a monomorphic type for `z`, and it will see that it needs to be `Int`. |
| 2020-10-04 01:17:27 | <dolio> | Which means that the literal's type is Int, and then it can warn. |
| 2020-10-04 01:17:44 | <dolio> | When you're doing it in GHCi, the literal's type is `forall a. Num a => a`. |
| 2020-10-04 01:17:59 | <zoom66> | so when constructing real-world logic, if there's ever a function that may exceed the bounds of Int, I guess I can't guess a polymorphic type variable? |
| 2020-10-04 01:18:03 | <dolio> | Because it's doing things line-by-line. |
| 2020-10-04 01:18:26 | <dolio> | So if it didn't leave it polymorphic, you wouldn't be able to use it at arbitrary other types later. |
| 2020-10-04 01:18:35 | <zoom66> | ok, got it |
| 2020-10-04 01:18:59 | <zoom66> | what if I have two Int that are polymorphic and do an operation where the result exceeds Int. Does it just wrap? |
| 2020-10-04 01:19:25 | <dolio> | Yes. There are packages with other Int types that will throw exceptions, though. |
| 2020-10-04 01:19:53 | <zoom66> | great, thanks |
| 2020-10-04 01:21:40 | × | OmegaDoug quits (8e749d03@lnsm3-torontoxn-142-116-157-3.internet.virginmobile.ca) (Remote host closed the connection) |
| 2020-10-04 01:22:01 | × | mozzarella quits (~sam@unaffiliated/sam113101) (Ping timeout: 256 seconds) |
| 2020-10-04 01:22:25 | × | raehik1 quits (~raehik@cpc96984-rdng25-2-0-cust109.15-3.cable.virginm.net) (Ping timeout: 240 seconds) |
| 2020-10-04 01:24:02 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie) |
| 2020-10-04 01:24:13 | → | GyroW joins (~GyroW@d54C03E98.access.telenet.be) |
| 2020-10-04 01:24:13 | × | GyroW quits (~GyroW@d54C03E98.access.telenet.be) (Changing host) |
| 2020-10-04 01:24:13 | → | GyroW joins (~GyroW@unaffiliated/gyrow) |
| 2020-10-04 01:27:10 | <Squarism> | I used to know why this was a bad idea but I've been away from haskell to long. |
| 2020-10-04 01:27:17 | × | jb55 quits (~jb55@gateway/tor-sasl/jb55) (Remote host closed the connection) |
| 2020-10-04 01:27:21 | <Squarism> | I want to create a function returning a generic interface. foo :: Int -> SomeGenericInterface. So I think classes + instance is the thing. So foo :: Int -> SomeClass a. But then I need to provide "a" at invokation. Is the right answer to create a datatype (unparamterized) SomeType with accessors for funktions I want in this generic interface? Classes are just usefule when working with a known type. |
| 2020-10-04 01:27:54 | → | wroathe_ joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-04 01:28:25 | × | wroathe quits (~wroathe@c-73-24-27-54.hsd1.mn.comcast.net) (Ping timeout: 240 seconds) |
| 2020-10-04 01:28:32 | × | wroathe_ quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Client Quit) |
| 2020-10-04 01:28:48 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-04 01:29:19 | → | jb55 joins (~jb55@gateway/tor-sasl/jb55) |
| 2020-10-04 01:32:01 | → | mozzarella joins (~sam@unaffiliated/sam113101) |
| 2020-10-04 01:33:12 | → | thir joins (~thir@p200300f27f0fc60004d129737887aa72.dip0.t-ipconnect.de) |
| 2020-10-04 01:37:55 | × | thir quits (~thir@p200300f27f0fc60004d129737887aa72.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-10-04 01:39:00 | <nitrix> | Squarism, Type classes don't appear like that on the right of an arrow. |
| 2020-10-04 01:39:19 | <Squarism> | Yeah, its coming back to me |
| 2020-10-04 01:39:39 | <nitrix> | Squarism, You normally have a type variable with a constraint to restrict it to one of the types that implements the typeclass. |
| 2020-10-04 01:39:41 | <Squarism> | Just feels like it would be possible to create classes where the type is not used in functions that could be "anonymous" like this. But I guess Its out of their scope |
| 2020-10-04 01:40:00 | <nitrix> | Squarism, e.g. foo :: SomeClass c => Int -> c a |
| 2020-10-04 01:40:09 | <Squarism> | yeah. |
| 2020-10-04 01:41:46 | <infinisil> | Squarism: You may be looking for existential types, see https://wiki.haskell.org/Existential_type |
| 2020-10-04 01:41:55 | × | Gurkenglas quits (~Gurkengla@unaffiliated/gurkenglas) (Ping timeout: 240 seconds) |
| 2020-10-04 01:46:28 | → | reallymemorable joins (~quassel@ip68-9-215-56.ri.ri.cox.net) |
| 2020-10-04 01:46:54 | × | conal quits (~conal@66.115.157.94) (Quit: Computer has gone to sleep.) |
| 2020-10-04 01:46:55 | × | xff0x quits (~fox@2001:1a81:528f:c400:e12b:e4ce:eff2:a3d5) (Ping timeout: 240 seconds) |
| 2020-10-04 01:47:22 | × | cr3 quits (~cr3@192-222-143-195.qc.cable.ebox.net) (Ping timeout: 272 seconds) |
| 2020-10-04 01:47:27 | <koz_> | I've noticed that most (effectful) streaming libraries (aside from conduit and io-streams) don't have a notion of 'peeking' a stream (namely, looking at the next value, but without removing it from said stream). How come this is the case? |
| 2020-10-04 01:48:47 | → | xff0x joins (~fox@2001:1a81:52c9:f600:e12b:e4ce:eff2:a3d5) |
| 2020-10-04 01:50:33 | → | polyrain joins (~polyrain@2001:8003:e501:6901:44d8:84ba:175f:dd38) |
| 2020-10-04 01:50:54 | → | cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net) |
| 2020-10-04 01:53:51 | → | conal joins (~conal@64.71.133.70) |
| 2020-10-04 01:55:23 | → | CMCDragonkai1 joins (~Thunderbi@120.17.204.172) |
| 2020-10-04 01:56:52 | × | mirrorbird quits (~psutcliff@2a00:801:42a:82eb:6edc:4c78:a574:2a8f) (Remote host closed the connection) |
| 2020-10-04 01:57:05 | → | mirrorbird joins (~psutcliff@2a00:801:42a:82eb:6edc:4c78:a574:2a8f) |
| 2020-10-04 01:59:29 | × | Tops2 quits (~Tobias@dyndsl-095-033-018-208.ewe-ip-backbone.de) (Read error: Connection reset by peer) |
| 2020-10-04 02:03:17 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2020-10-04 02:04:55 | × | thc202 quits (~thc202@unaffiliated/thc202) (Ping timeout: 240 seconds) |
| 2020-10-04 02:05:50 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-04 02:09:10 | × | ryansmccoy quits (~ryansmcco@68.235.48.108) (Ping timeout: 246 seconds) |
| 2020-10-04 02:09:47 | → | ryansmccoy joins (~ryansmcco@156.96.151.132) |
| 2020-10-04 02:13:51 | × | mirrorbird quits (~psutcliff@2a00:801:42a:82eb:6edc:4c78:a574:2a8f) (Ping timeout: 272 seconds) |
| 2020-10-04 02:14:25 | × | ericsagnes quits (~ericsagne@2405:6580:0:5100:80c3:1766:ef39:bb4c) (Ping timeout: 240 seconds) |
| 2020-10-04 02:16:54 | → | HaskellYogi joins (~vivekrama@49.207.213.15) |
| 2020-10-04 02:18:12 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Quit: leaving) |
| 2020-10-04 02:23:03 | → | elliott__ joins (~elliott@pool-108-45-154-71.washdc.fios.verizon.net) |
| 2020-10-04 02:23:43 | × | cr3 quits (~cr3@192-222-143-195.qc.cable.ebox.net) (Quit: leaving) |
| 2020-10-04 02:26:28 | × | nbloomf quits (~nbloomf@2600:1700:83e0:1f40:7c32:dfd5:ea25:990f) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-04 02:27:24 | → | ericsagnes joins (~ericsagne@2405:6580:0:5100:9458:e3c2:d11d:f00a) |
| 2020-10-04 02:30:49 | → | sand_dull joins (~theuser@cpe-67-252-1-237.nycap.res.rr.com) |
| 2020-10-04 02:31:25 | × | LKoen quits (~LKoen@lstlambert-657-1-123-43.w92-154.abo.wanadoo.fr) (Read error: Connection reset by peer) |
| 2020-10-04 02:31:32 | → | LKoen joins (~LKoen@lstlambert-657-1-123-43.w92-154.abo.wanadoo.fr) |
| 2020-10-04 02:32:13 | × | zoom66 quits (44beb1c9@068-190-177-201.res.spectrum.com) (Remote host closed the connection) |
All times are in UTC.