Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-12 02:25:00 dbmikus joins (~dbmikus@cpe-76-167-86-219.natsow.res.rr.com)
2021-03-12 02:25:10 elfets joins (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de)
2021-03-12 02:25:18 × Kaiepi quits (~Kaiepi@47.54.252.148) (Remote host closed the connection)
2021-03-12 02:25:22 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2021-03-12 02:26:54 Kaiepi joins (~Kaiepi@47.54.252.148)
2021-03-12 02:27:21 conal joins (~conal@64.71.133.70)
2021-03-12 02:29:45 × dbmikus quits (~dbmikus@cpe-76-167-86-219.natsow.res.rr.com) (Ping timeout: 246 seconds)
2021-03-12 02:33:38 bergey joins (~user@pool-74-108-99-127.nycmny.fios.verizon.net)
2021-03-12 02:34:17 <curiousgay> Axman6: minoru_shiraeesh: select and poll are slower than linux's epoll and bsd's kqueue, also depending on use case you might want to use libevent https://libevent.org/ to abstract useage of these platform-specific interfaces
2021-03-12 02:37:33 × nhs quits (~nhs@cpe-70-113-67-118.austin.res.rr.com) (Ping timeout: 245 seconds)
2021-03-12 02:37:45 × cheater quits (~user@unaffiliated/cheater) (Ping timeout: 264 seconds)
2021-03-12 02:37:46 drbean joins (~drbean@TC210-63-209-174.static.apol.com.tw)
2021-03-12 02:38:19 cheater joins (~user@unaffiliated/cheater)
2021-03-12 02:38:30 × bergey quits (~user@pool-74-108-99-127.nycmny.fios.verizon.net) (Ping timeout: 246 seconds)
2021-03-12 02:39:16 × tomku quits (~tomku@unaffiliated/tomku) (Quit: Lost terminal)
2021-03-12 02:41:07 × zangi quits (~azure@103.154.230.250) (Ping timeout: 256 seconds)
2021-03-12 02:42:07 Tario joins (~Tario@201.192.165.173)
2021-03-12 02:42:48 <infinisil> Alternative instances are awesome
2021-03-12 02:43:01 zangi joins (~azure@103.154.230.242)
2021-03-12 02:43:16 <infinisil> Recently was able to use Concurrently's Alternative instance to run threads in parallel
2021-03-12 02:43:17 nhs joins (~nhs@cpe-70-113-67-118.austin.res.rr.com)
2021-03-12 02:43:54 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:ac7b:d5c9:2180:6a41) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-03-12 02:44:00 <infinisil> And via slack1256 I learned about STM's Alternative instance, which is just empty = retry and <|> = orElse
2021-03-12 02:44:05 <infinisil> Which is pretty cool
2021-03-12 02:44:21 <slack1256> Yep, makes eventloop real neat.
2021-03-12 02:44:48 × redmp_ quits (~redmp@172.58.19.17) (Ping timeout: 260 seconds)
2021-03-12 02:45:45 <infinisil> Though looking at Alternative, I have no idea what `some` and `many` do
2021-03-12 02:46:12 <infinisil> The docs just say "One or more." and "Zero or more.", which is as vague as can be
2021-03-12 02:46:14 <monochrom> They make most sense for parsers.
2021-03-12 02:46:16 <slack1256> In terms of regexes, some is * and many is +.
2021-03-12 02:46:34 Lord_of_Life_ joins (~Lord@unaffiliated/lord-of-life/x-0885362)
2021-03-12 02:47:18 <infinisil> > some (Just 1)
2021-03-12 02:47:20 <lambdabot> *Exception: <<loop>>
2021-03-12 02:47:33 × xff0x_ quits (~xff0x@2001:1a81:53d2:5300:7d58:fd61:d678:3ab7) (Ping timeout: 272 seconds)
2021-03-12 02:47:35 <infinisil> > some [1]
2021-03-12 02:47:38 <lambdabot> *Exception: <<loop>>
2021-03-12 02:47:44 <monochrom> But you can also have an STM action that if you run repeatedly, it succeeds for the first few times, and fails once. Then many and some stops there and returns the list of the answers you got from the successes.
2021-03-12 02:47:57 × nhs quits (~nhs@cpe-70-113-67-118.austin.res.rr.com) (Ping timeout: 264 seconds)
2021-03-12 02:48:12 tomku joins (~tomku@unaffiliated/tomku)
2021-03-12 02:48:23 × Lord_of_Life quits (~Lord@unaffiliated/lord-of-life/x-0885362) (Ping timeout: 245 seconds)
2021-03-12 02:48:23 Lord_of_Life_ is now known as Lord_of_Life
2021-03-12 02:48:29 redmp joins (~redmp@172.58.30.171)
2021-03-12 02:48:30 <monochrom> It makes no sense for Maybe. Or generally actions that always succeeds or always fails.
2021-03-12 02:48:45 <monochrom> Well, many is OK with always fails. But that's all.
2021-03-12 02:48:49 <infinisil> Hmm..
2021-03-12 02:48:54 <monochrom> > many Nothing
2021-03-12 02:48:55 <lambdabot> Just []
2021-03-12 02:49:02 xff0x_ joins (~xff0x@2001:1a81:520c:1100:8f7b:fec1:f600:70b)
2021-03-12 02:49:14 <infinisil> Whaaa
2021-03-12 02:50:08 <monochrom> Generally, with "many foo" or "some foo", you expect to run foo several times, it succeeds the first few times, then fails.
2021-03-12 02:50:08 <infinisil> Oh, so it relies on the Applicative instance
2021-03-12 02:50:24 × zangi quits (~azure@103.154.230.242) (Ping timeout: 246 seconds)
2021-03-12 02:50:25 <infinisil> I kind of see
2021-03-12 02:50:56 nbloomf joins (~nbloomf@2600:1700:ad14:3020:ac7b:d5c9:2180:6a41)
2021-03-12 02:52:10 <infinisil> So `some` repeatedly runs the `f a` until it's `empty`?
2021-03-12 02:52:17 <monochrom> The whole of Alternative was inspired by parsing. The notation shows.
2021-03-12 02:52:24 zangi joins (~azure@103.154.230.250)
2021-03-12 02:52:32 <infinisil> Or what does "failure" mean?
2021-03-12 02:52:42 <monochrom> some wants at least one success, and repeats until empty.
2021-03-12 02:52:58 <monochrom> many is OK with 0 successes, empty right away.
2021-03-12 02:53:06 <monochrom> failure = empty
2021-03-12 02:53:59 <monochrom> Both want to hit empty after a finite number of times, so they can stop and return a finite list of answers.
2021-03-12 02:54:37 <infinisil> I see, and from the implementation I can see that it uses `<|>` to decide whether the result is empty or not
2021-03-12 02:54:47 <monochrom> If always successful, they become unproductive infinite loops hoping for an empty that will never come.
2021-03-12 02:54:57 <monochrom> Yeah.
2021-03-12 02:55:03 <infinisil> Though laziness
2021-03-12 02:55:17 <infinisil> > take 10 $ some (Just 1)
2021-03-12 02:55:19 <lambdabot> error:
2021-03-12 02:55:19 <lambdabot> • Couldn't match type ‘Maybe’ with ‘[]’
2021-03-12 02:55:19 <lambdabot> Expected type: [[a]]
2021-03-12 02:55:22 <infinisil> > take 10 <$> some (Just 1)
2021-03-12 02:55:25 <lambdabot> *Exception: <<loop>>
2021-03-12 02:55:27 azure1 joins (~azure@103.154.230.242)
2021-03-12 02:55:30 <infinisil> Oor not
2021-03-12 02:55:36 <monochrom> Naw, you're betting on <*> being lazy then. But <*> is not lazy for most instances.
2021-03-12 02:56:21 <monochrom> "liftA2 (:) foo bar" will very much want to resolve foo at the very least, and most often bar too.
2021-03-12 02:57:36 <infinisil> Hmm
2021-03-12 02:58:06 × zangi quits (~azure@103.154.230.250) (Ping timeout: 265 seconds)
2021-03-12 02:58:22 <infinisil> > seq (some (Just 1)) 0
2021-03-12 02:58:25 <lambdabot> *Exception: <<loop>>
2021-03-12 02:58:51 <infinisil> So `some (Just 1)` is `Just [1..]`, except that not even the `Just` can be evaluated?
2021-03-12 02:59:23 <monochrom> I'm afraid you don't even get to see the Just.
2021-03-12 03:00:03 nhs joins (~nhs@cpe-70-113-67-118.austin.res.rr.com)
2021-03-12 03:00:49 <infinisil> Ah looking at Maybe's Applicative I see
2021-03-12 03:00:51 <infinisil> liftA2 f (Just x) (Just y) = Just (f x y)
2021-03-12 03:00:56 <infinisil> liftA2 _ _ _ = Nothing
2021-03-12 03:01:04 <monochrom> Roughly: some (Just 1) = liftA2 (:) (Just 1) (some (Just 1)) = liftA2 (:) (Just 1) (liftA2 (:) (Just 1) (some (Just 1))) = ...
2021-03-12 03:01:39 <infinisil> I see
2021-03-12 03:02:27 × redmp quits (~redmp@172.58.30.171) (Ping timeout: 265 seconds)
2021-03-12 03:02:40 <infinisil> Is there a separate type class hidden in there? Something between Applicative and Alternative that doesn't have some/many because you can't ever evaluate them?
2021-03-12 03:04:03 <monochrom> some and many are codable by Applicative and <|> and empty and recursion. If Alternative didn't have them, you can still always have them outside and the constraint is merely "Alternative f =>".
2021-03-12 03:04:45 × nhs quits (~nhs@cpe-70-113-67-118.austin.res.rr.com) (Ping timeout: 246 seconds)
2021-03-12 03:04:54 × myShoggoth quits (~myShoggot@75.164.81.55) (Ping timeout: 260 seconds)
2021-03-12 03:05:05 <infinisil> Ah makes sense
2021-03-12 03:05:06 <monochrom> Oh but they're bottom for many instances? Well that's just too bad.
2021-03-12 03:05:27 × CrazyPyt_ quits (~crazypyth@98.122.164.118) (Ping timeout: 246 seconds)
2021-03-12 03:05:33 <infinisil> I guess they're part of Alternative in case you can provide a more efficient version?
2021-03-12 03:06:00 <monochrom> But if you admit them into Alternative, then you save a mental vocab burden, and you enable hand-optimizations for those instances that could use the help.
2021-03-12 03:06:07 <monochrom> yeah.
2021-03-12 03:06:37 <monochrom> But I think reducing vocab burden is more valuable.

All times are in UTC.