Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-26 19:22:53 cosimone joins (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd)
2020-11-26 19:23:21 <avdb> Is there a way to get the index of an element in a list comprehension?
2020-11-26 19:23:37 × christo quits (~chris@81.96.113.213) (Ping timeout: 264 seconds)
2020-11-26 19:23:39 <merijn> Zip it with an list of indices? :p
2020-11-26 19:23:58 <avdb> I want [x | x <- lst] but without the odd indexes of lst
2020-11-26 19:24:00 × phaul quits (~phaul@ruby/staff/phaul) (Remote host closed the connection)
2020-11-26 19:24:11 <tomsmeding> merijn: also if not ambiguous: https://downloads.haskell.org/ghc/latest/docs/html/users_guide/using-warnings.html#ghc-flag--Wunticked-promoted-constructors is enabled with -Wall
2020-11-26 19:24:22 <merijn> tomsmeding: That's new
2020-11-26 19:24:34 <merijn> Wonder when that got added
2020-11-26 19:24:35 <tomsmeding> perhaps, but it's true now nevertheless :p
2020-11-26 19:24:47 phaul joins (~phaul@ruby/staff/phaul)
2020-11-26 19:24:50 <tomsmeding> I believe we two actually talked about this before in this very channel :p
2020-11-26 19:25:00 <monochrom> [x | (x,i) <- zip lst (cycle [True,False]), i]
2020-11-26 19:25:32 <avdb> You mean [(x,y) | x <- lst, y <- index, mod (snd y) 2 == 0] ?
2020-11-26 19:25:41 <monochrom> No. I mean what I wrote.
2020-11-26 19:25:49 <monochrom> What you wrote provably does something else.
2020-11-26 19:26:05 <tomsmeding> merijn: https://ircbrowse.tomsmeding.com/day/haskell/2020/11/07?id=111296&timestamp=1604764844#t1604764844
2020-11-26 19:26:07 <avdb> monochrom: Thanks. Doing exercises to learn new built-in functions is much more useful than reading books for me.
2020-11-26 19:26:20 <monochrom> Let's see what's so wrong:
2020-11-26 19:26:37 <avdb> That was my own function. I was planning on creating tuples with the index as the second element.
2020-11-26 19:26:45 <avdb> And just filtering the odd ones.
2020-11-26 19:27:17 × justanotheruser quits (~justanoth@unaffiliated/justanotheruser) (Ping timeout: 272 seconds)
2020-11-26 19:27:24 <monochrom> With a moment of thought, you don't need full natural numbers, you just need cycle [True,False]
2020-11-26 19:28:04 <monochrom> Gödel was damaging in teaching us to always work with natural numbers only.
2020-11-26 19:28:15 <tomsmeding> did he?
2020-11-26 19:28:16 <monochrom> Turing was damaging in teaching us to always work with strings only.
2020-11-26 19:28:25 <ski> oh, there's an IRC Browse on the run again
2020-11-26 19:28:42 × BRRR quits (5b8169f5@m91-129-105-245.cust.tele2.ee) (Remote host closed the connection)
2020-11-26 19:28:50 <monochrom> Oh very strongly. Look up Gödel numbering. An XY problem in avoiding even strings.
2020-11-26 19:28:57 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed)
2020-11-26 19:29:05 <monochrom> or generally arrays.
2020-11-26 19:29:18 <tomsmeding> he certainly did cool tricks with natural numbers, but did he teach us to work with natural numbers only? I don't think so :)
2020-11-26 19:29:20 <opqdonut> there are also the folklore functions "evens (x:xs) = x:odds xs; odds (_:xs) = evens xs"
2020-11-26 19:29:22 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2020-11-26 19:29:52 <opqdonut> which are useful if you only need every second element (and don't need to generalize to e.g. every third)
2020-11-26 19:29:56 <xerox_> the GHC manual did have a citation http://dreixel.net/research/pdf/ghp.pdf
2020-11-26 19:29:56 <monochrom> Scott Aaronson had great fun mocking Gödel numbering.
2020-11-26 19:30:07 <merijn> ski: tomsmeding apparently wanted to do a bunch of work no one was feeling like, so we tricked him into running a copy now that Chris' is gone :p
2020-11-26 19:30:29 <tomsmeding> it compiles on a recent ghc now too :)
2020-11-26 19:31:24 <monochrom> Along the line of "I have a mathematician friend who is learning programming, he didn't learn arrays but he wanted to do arrays, so he thought up this great idea, represent [a,b,c] by 2^a 3^b 5^c. That's Gödel numbering."
2020-11-26 19:32:00 <xerox_> zipWith (^) primes
2020-11-26 19:32:04 <tomsmeding> obligatory mention of https://esolangs.org/wiki/Fractran
2020-11-26 19:32:28 <opqdonut> gödel numbering predates pretty much all programming so we can forgive it for being a bit esoteric :P
2020-11-26 19:32:42 <opqdonut> I think I've seen a version of gödel's proof that uses a more modern encoding
2020-11-26 19:32:49 mputz joins (~Thunderbi@dslb-084-058-211-084.084.058.pools.vodafone-ip.de)
2020-11-26 19:33:18 <xerox_> did they use capt'n'proto or protocol buffers
2020-11-26 19:33:19 <monochrom> Well OK, you are right that maybe he didn't intend to teach us to use natural numbers only. But the empirical effect is he ended up achieving that.
2020-11-26 19:33:51 <opqdonut> xerox_: json and unicode, obviously ;)
2020-11-26 19:34:00 jollygood2 joins (~bc8165ab@217.29.117.252)
2020-11-26 19:34:12 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 256 seconds)
2020-11-26 19:34:35 <jollygood2> @hoogle Random a => [a] -> IO a
2020-11-26 19:34:36 <lambdabot> Rando pickOne :: [x] -> IO x
2020-11-26 19:34:36 <lambdabot> System.Random.Pick pickOne :: [x] -> IO x
2020-11-26 19:34:36 <lambdabot> Basement.Monad unsafePrimToIO :: PrimMonad prim => prim a -> IO a
2020-11-26 19:34:40 × invaser quits (~Thunderbi@31.148.23.125) (Quit: invaser)
2020-11-26 19:34:42 <monochrom> Namely, we all understand that Gödel numbering is completely non-essential and replaceable (by strings, even ASTs) for his proofs, but most people still teach the Gödel numbering versions of the proof exclusively.
2020-11-26 19:34:46 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2020-11-26 19:34:46 <jollygood2> anything in base?
2020-11-26 19:35:00 invaser joins (~Thunderbi@31.148.23.125)
2020-11-26 19:35:10 <tomsmeding> jollygood2: the Random class itself isn't even in base :p
2020-11-26 19:35:10 × fendor quits (~fendor@77.119.130.234.wireless.dyn.drei.com) (Remote host closed the connection)
2020-11-26 19:35:28 <jollygood2> s/base/package that ships with ghc
2020-11-26 19:35:53 <tomsmeding> unfortunately no, 'random' is the usual package, though there are others with more high-performance generators
2020-11-26 19:36:15 <tomsmeding> also, 'Random' itself is not from a package that ships with ghc, so my point stands :p
2020-11-26 19:36:22 <dolio> I'm not sure that's on Gödel. It's kind of the mathematician equivalent of programmers who want to write everything 'close to the machine.'
2020-11-26 19:36:32 <jollygood2> Random doesn't ship with ghc?
2020-11-26 19:36:38 <monochrom> My thesis supervisor's sentiment is in http://www.cs.toronto.edu/~hehner/God.pdf and I totally agree, today even the purest mathematicians have the tools to obsolete the Gödel encoding.
2020-11-26 19:36:51 <tomsmeding> jollygood2: it's from the 'random' package :p
2020-11-26 19:37:06 <jollygood2> that doesn't answer my question
2020-11-26 19:37:31 <tomsmeding> ... which doesn't ship with ghc, no
2020-11-26 19:38:08 <tomsmeding> because ghc ships only with the packages that ghc depends on, and ghc doesn't need to generate random numbers
2020-11-26 19:38:19 <monochrom> OK yeah dolio, your take is right.
2020-11-26 19:38:34 <monochrom> Oh well, so much for blaming it on celebrities.
2020-11-26 19:38:58 × oish quits (~charlie@228.25.169.217.in-addr.arpa) (Ping timeout: 260 seconds)
2020-11-26 19:39:22 Sgeo joins (~Sgeo@ool-18b982ad.dyn.optonline.net)
2020-11-26 19:39:40 <monochrom> Oh, random-1.2 is fast and high-quality IMO, even when you use split heavily.
2020-11-26 19:39:56 <jollygood2> I don't care about speed
2020-11-26 19:39:59 × machinedgod quits (~machinedg@135-23-192-217.cpe.pppoe.ca) (Remote host closed the connection)
2020-11-26 19:40:11 <monochrom> Actually the high-quality part can be objectively quantified by the statistics tests they took, e.g. Die Hard 1.
2020-11-26 19:40:12 <jollygood2> I just didn't want to depend on more packages than I need to
2020-11-26 19:40:42 <monochrom> Its dependency is minimal too. Just splitmix (the actual generator)
2020-11-26 19:40:43 <tomsmeding> the Random class is from the 'random' package, which ghc does not depend on, so you'll need that one at least -- and that ships with a RNG too, so it's all you need
2020-11-26 19:40:45 <dolio> Similar phenomenon to everyone insisting on ZF(C) as a formal foundation, and getting really obstinate about not using one that lets you write down things similar to what mathematicians actually say in a more direct way. Despite having very little experience actually working formally. :)
2020-11-26 19:41:00 <merijn> monochrom: As always the blame lies with "people being people"
2020-11-26 19:41:07 machinedgod joins (~machinedg@135-23-192-217.cpe.pppoe.ca)
2020-11-26 19:41:31 <monochrom> IKR? I'm supposed to be cynical about all humanity.
2020-11-26 19:41:32 <merijn> There's a super fast RNG in base if you don't care about quality :p
2020-11-26 19:41:38 <merijn> "4"
2020-11-26 19:42:44 <dolio> I actually saw someone on MathOverflow recently talking about how the nonsensical propositions in ZF enable 'clever hacks', and that's a good thing. Which makes even less sense than when programmers advocate for it. :)
2020-11-26 19:42:58 <jollygood2> randomPick xs = (xs!!) <$> randomRIO (0, length xs)
2020-11-26 19:43:06 <tomsmeding> I mean, if quality is not a great issue, you can write a 128-bit LCG without a large amount of effort or code, which will work fine :p
2020-11-26 19:43:17 <int-e> merijn: with the xkcd stamp of approval?
2020-11-26 19:43:28 <jollygood2> length xs - 1
2020-11-26 19:43:49 <merijn> int-e: Exactly
2020-11-26 19:45:43 DirefulSalt joins (DirefulSal@gateway/vpn/privateinternetaccess/direfulsalt)
2020-11-26 19:48:56 orion joins (~orion@c-76-19-238-5.hsd1.nh.comcast.net)
2020-11-26 19:48:56 × orion quits (~orion@c-76-19-238-5.hsd1.nh.comcast.net) (Changing host)
2020-11-26 19:48:56 orion joins (~orion@unaffiliated/orion)
2020-11-26 19:50:10 Finianb1 joins (~Finianb1@71-218-235-186.hlrn.qwest.net)
2020-11-26 19:51:18 × n0042 quits (d055ed89@208.85.237.137) (Remote host closed the connection)

All times are in UTC.