Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→
Page 1 .. 586 587 588 589 590 591 592 593 594 595 596 .. 18009
1,800,846 events total
2021-06-22 14:02:03 <thyriaen> i have not reached $ yet
2021-06-22 14:02:10 <[exa]> ah okay worry not then
2021-06-22 14:02:12 × trcc quits (~trcc@130.225.16.16) (Ping timeout: 265 seconds)
2021-06-22 14:02:18 <thyriaen> yes
2021-06-22 14:02:19 <[exa]> it just applies function on the left to the parameter on the right
2021-06-22 14:02:26 <thyriaen> cool
2021-06-22 14:02:38 <[exa]> really can avoid a lot of )))))))))))))
2021-06-22 14:03:28 <thyriaen> so if i would write isEvenLength, i would go through the list and return a boolean depending when the list ends
2021-06-22 14:03:29 wallymathieu joins (~wallymath@81-234-151-21-no94.tbcn.telia.com)
2021-06-22 14:03:30 o1lo01ol1o joins (~o1lo01ol1@bl7-89-228.dsl.telepac.pt)
2021-06-22 14:04:03 <[exa]> e.g. `pure (f 1 (g 2 3))` can be written as `pure $ f 1 $ g 2 3`
2021-06-22 14:04:05 notzmv joins (~zmv@user/notzmv)
2021-06-22 14:05:15 <[exa]> thyriaen: yeah. Note you don't produce the unnecessary Int in the process
2021-06-22 14:06:03 × Morrow_ quits (~MorrowM_@147.161.9.235) (Ping timeout: 258 seconds)
2021-06-22 14:06:08 <thyriaen> [exa], so i my case i have a function toDigitsRev :: Integer -> [Integer] and i can just write reverse $ toDigitsRev [1,2] instead of reverse(toDigitsRev [1,2]) ?
2021-06-22 14:06:33 <[exa]> yeah that should work
2021-06-22 14:07:03 <[exa]> (at least if there aren't any more parameters to reverse, which I guess there isn't)
2021-06-22 14:07:12 <[exa]> (aren't)
2021-06-22 14:07:25 <thyriaen> [exa], okay thanks - I didn't fully understand how i can put these things together, but let me write up the single functions and fiddle with them a bit
2021-06-22 14:07:36 <thyriaen> then ill be back if i can still not get the answer
2021-06-22 14:07:58 <[exa]> ok
2021-06-22 14:08:24 <[exa]> extra inspiration for avoiding explicit Booleans: compare (tail $ cycle [1,2]) and (id $ cycle [1,2])
2021-06-22 14:08:50 slowButPresent joins (~slowButPr@user/slowbutpresent)
2021-06-22 14:08:51 <thyriaen> is id a keyword ?
2021-06-22 14:09:22 <[exa]> no, just a normal function that doesn't change the parameter
2021-06-22 14:09:26 <thyriaen> ok
2021-06-22 14:09:37 <[exa]> pretty useful for various placeholding and dummy values
2021-06-22 14:09:49 <nitrix> id x = x
2021-06-22 14:10:22 <thyriaen> its just the idendity function
2021-06-22 14:10:29 <[exa]> yes
2021-06-22 14:11:28 <thyriaen> doesnt cycle need another argument how many times it needs to cycle ?
2021-06-22 14:11:47 janiczek joins (~janiczek@89-24-215-117.customers.tmcz.cz)
2021-06-22 14:11:48 fendor_ joins (~fendor@178.115.129.107.wireless.dyn.drei.com)
2021-06-22 14:11:56 <Taneb> thyriaen: nope, it just keeps going
2021-06-22 14:12:10 × Xraell quits (~yourname@45.157.15.145) (Remote host closed the connection)
2021-06-22 14:13:06 <thyriaen> how can i make it stop T_T cycle 3 [1,2] ?
2021-06-22 14:13:48 <tdammers> you can just take as much of it as you need
2021-06-22 14:13:58 <thyriaen> tdammers, haha
2021-06-22 14:14:00 <nitrix> cycle produces an infinite list but you can take a shorter list from that list.
2021-06-22 14:14:14 × fendor quits (~fendor@91.141.3.62.wireless.dyn.drei.com) (Ping timeout: 252 seconds)
2021-06-22 14:15:01 <tdammers> I was being serious. Remember that Haskell does non-strict evaluation by default, so just let-binding an expression that would evaluate to an infinitely long list does not actually allocate an infinitely long list in memory, nor does it take infinitely long to bind it
2021-06-22 14:15:17 <tdammers> that list only gets evaluated as far as is demanded
2021-06-22 14:15:41 <tdammers> so if you say `take 10 (cycle [1,2])`, it'll evaluate as many list items as necessary to get you the first 10 elements
2021-06-22 14:15:52 safinaskar joins (~safinaska@109.252.90.89)
2021-06-22 14:15:55 <thyriaen> tdammers, it was funny because i did not know there was a "take" function and id did sound so natural to just take a few
2021-06-22 14:16:10 <tdammers> well, yeah, it's called take for a reason
2021-06-22 14:16:15 <thyriaen> ;p
2021-06-22 14:16:26 <safinaskar> hi. https://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Applicative.html says that "fmap f x = pure f <*> x" follows from other applicative laws. how to prove this?
2021-06-22 14:16:45 <nitrix> Alternatively, you could use `replicate`, which accepts a number of times and something to replicate, so `replicate 3 [1,2]`, but that would produce the list [[1,2], [1,2], [1,2]] which you would then have to concatenate them all as [1,2,1,2,1,2] with the function `concat`.
2021-06-22 14:17:10 <nitrix> % concat $ replicate 3 [1,2]
2021-06-22 14:17:10 <yahb> nitrix: [1,2,1,2,1,2]
2021-06-22 14:17:38 Sgeo joins (~Sgeo@user/sgeo)
2021-06-22 14:18:30 <nitrix> It avoids the little bit of arithmetic of multiplying the cycle count with the cycle length to `take` the right amount.
2021-06-22 14:22:46 <[exa]> thyriaen: zipWith automagically truncates the longer list for you
2021-06-22 14:22:49 tzh joins (~tzh@c-24-21-73-154.hsd1.or.comcast.net)
2021-06-22 14:23:21 <[exa]> > zipWith (+) (cycle [1,2]) [1,2,3,4]
2021-06-22 14:23:23 <lambdabot> [2,4,4,6]
2021-06-22 14:24:04 <lyxia> safinaskar: \f x -> pure f <*> x satisfies the functor laws and by parametricity there is only one function that satisfies the functor laws.
2021-06-22 14:24:56 <safinaskar> lyxia: "parametricity" - you mean theorems for free?
2021-06-22 14:25:04 <lyxia> yes
2021-06-22 14:25:09 <safinaskar> thanks
2021-06-22 14:26:57 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:e846:fcb5:a54b:afb8)
2021-06-22 14:27:00 <kw> `<*>` still has to satisfy the Applicative laws for that to work, though.
2021-06-22 14:27:23 <lyxia> yeah but the question is about why the docs say "follows from the other applicative laws"
2021-06-22 14:27:23 <kw> As does `pure` .
2021-06-22 14:28:16 fendor_ is now known as fendor
2021-06-22 14:30:03 <kw> Right. I'm just saying that 'It follows from the Applicative laws' by parametricity.' does not explain why that is true.
2021-06-22 14:31:06 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:e846:fcb5:a54b:afb8) (Ping timeout: 240 seconds)
2021-06-22 14:31:36 × kw quits (~user@152.1.137.158) (Quit: work)
2021-06-22 14:32:35 finsternis joins (~X@23.226.237.192)
2021-06-22 14:33:11 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Remote host closed the connection)
2021-06-22 14:33:22 × trent2 quits (~trent@2001:8003:340d:d00:b2de:b98:7a93:b0ea) (Ping timeout: 244 seconds)
2021-06-22 14:35:27 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-06-22 14:38:17 <thyriaen> [exa], neat ! how considerate of zipWith
2021-06-22 14:38:32 safinaskar parts (~safinaska@109.252.90.89) ()
2021-06-22 14:39:06 <thyriaen> [exa], but in essence, i have to run length on my initial list first to check which one to take, no ?
2021-06-22 14:39:31 <thyriaen> or how do i get the oddness of the list without the explict boolean ?
2021-06-22 14:40:10 × cfricke quits (~cfricke@user/cfricke) (Quit: WeeChat 3.1)
2021-06-22 14:40:33 Guest31 joins (~Guest31@202.166.32.155)
2021-06-22 14:42:41 <Guest31> is this the correct place to ask beginner questions regarding Haskell? I just started on the fp-course on windows and was facing some difficulty with basic setup
2021-06-22 14:44:12 × mikoto-chan quits (~mikoto-ch@ip-213-49-189-31.dsl.scarlet.be) (Quit: mikoto-chan)
2021-06-22 14:45:09 × peterhil quits (~peterhil@dsl-hkibng32-54f849-252.dhcp.inet.fi) (Ping timeout: 258 seconds)
2021-06-22 14:45:16 <[exa]> thyriaen: you can return `id` if the length's even or `tail` if the length is odd, and just apply that to the `cycle [1,2]` to conditionally drop the first item
2021-06-22 14:45:48 × curiousgay quits (~curiousgg@178.217.208.8) (Remote host closed the connection)
2021-06-22 14:45:53 peterhil joins (~peterhil@dsl-hkibng32-54f849-252.dhcp.inet.fi)
2021-06-22 14:46:05 curiousgay joins (~curiousgg@178.217.208.8)
2021-06-22 14:46:18 <thyriaen> [exa], yea - but in order to determine that i have to first check if the length is indeed odd or even
2021-06-22 14:46:21 <thyriaen> i cannot get around that
2021-06-22 14:46:54 × hmmmas quits (~chenqisu1@183.217.200.246) (Quit: Leaving.)
2021-06-22 14:47:23 <L29Ah> hello, i'm trying to use the new OverloadedRecordDot syntax extension, i've enabled it and dependencies, and now have the following error in irrelevant code:
2021-06-22 14:47:23 <L29Ah> Not in scope: ‘setField’
2021-06-22 14:47:23 <L29Ah> 94 | let preTAM = def{salt = salt}
2021-06-22 14:47:28 <L29Ah> do i need to import something else?
2021-06-22 14:47:58 × mikail__ quits (~mikail@90.212.77.3) (Ping timeout: 252 seconds)
2021-06-22 14:50:32 hounded joins (~hounded@2603-7000-da43-eccc-0000-0000-0000-0cec.res6.spectrum.com)
2021-06-22 14:50:58 <hounded> #
2021-06-22 14:51:25 × nerdypepper quits (~nerdypepp@user/nerdypepper) (Quit: bye)
2021-06-22 14:51:26 <Guest31> i've cloned the fp-course directory and used chocolatey to install make; i've also installed stack and am able to execute stack ghci without issue for example. However if i try make GHCI i get the following error:
2021-06-22 14:51:30 <Guest31> STACK_YAML="stack.yaml" stack ghci course:lib
2021-06-22 14:51:30 <Guest31> 'STACK_YAML' is not recognized as an internal or external command,

All times are in UTC.