2023/12/10

2023-12-10 00:02:59 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com) (Ping timeout: 264 seconds)
2023-12-10 00:05:13 +0000tommy___(~tommy@2601:681:5a00:a260:2216:9438:8afd:c460) (Ping timeout: 246 seconds)
2023-12-10 00:08:47 +0000Tuplanolla(~Tuplanoll@91-159-68-236.elisa-laajakaista.fi) (Quit: Leaving.)
2023-12-10 00:10:07 +0000waleee(~waleee@h-176-10-144-38.NA.cust.bahnhof.se) (Ping timeout: 256 seconds)
2023-12-10 00:14:42 +0000idgaen(~idgaen@2a01:e0a:498:fd50:fcc6:bb5d:489a:ce8c) (Quit: WeeChat 4.1.1)
2023-12-10 00:18:55 +0000mhatta(~mhatta@www21123ui.sakura.ne.jp) (Quit: ZNC 1.8.2+deb3.1 - https://znc.in)
2023-12-10 00:23:16 +0000lane(~lane@pool-98-113-180-17.nycmny.fios.verizon.net) (Ping timeout: 276 seconds)
2023-12-10 00:25:53 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 00:26:59 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Client Quit)
2023-12-10 00:29:40 +0000mhatta(~mhatta@www21123ui.sakura.ne.jp)
2023-12-10 00:36:28 +0000lane(~lane@pool-98-113-180-17.nycmny.fios.verizon.net)
2023-12-10 00:36:31 +0000juri____(~juri@79.140.117.56)
2023-12-10 00:39:37 +0000juri_(~juri@79.140.117.90) (Ping timeout: 255 seconds)
2023-12-10 00:57:00 +0000cimento(CO2@gateway/vpn/protonvpn/cimento) (Quit: WeeChat 4.1.2)
2023-12-10 01:02:14 +0000califax(~califax@user/califx) (Remote host closed the connection)
2023-12-10 01:03:43 +0000machinedgod(~machinedg@93-136-130-2.adsl.net.t-com.hr) (Ping timeout: 260 seconds)
2023-12-10 01:08:37 +0000newsham(~newsham@2603-800c-2c01-6825-857b-69b9-29f4-97e6.res6.spectrum.com)
2023-12-10 01:10:12 +0000 <newsham> I can write identity and composition for pairs of functions (https://paste.debian.net/1300666/).  Is it possible to write a Category instance for this?
2023-12-10 01:12:41 +0000sawilagar(~sawilagar@user/sawilagar) (Remote host closed the connection)
2023-12-10 01:12:52 +0000 <int-e> :t arr
2023-12-10 01:12:53 +0000 <lambdabot> Arrow a => (b -> c) -> a b c
2023-12-10 01:13:06 +0000sawilagar(~sawilagar@user/sawilagar)
2023-12-10 01:13:13 +0000califax(~califax@user/califx)
2023-12-10 01:13:59 +0000 <newsham> ahh yah
2023-12-10 01:18:29 +0000emmanuelux_(~emmanuelu@user/emmanuelux)
2023-12-10 01:19:32 +0000 <[Leary]> newsham: Sounds like you want the product category? You'd need to use GADT trickery to pair up the objects. Something like `data ProdCat p q is js where ProdCat :: p i j -> q i' j' -> ProdCat p q '(i, i') '(j, j')` with `instance (Category p, Category q) => Category (ProdCat p q)`.
2023-12-10 01:19:39 +0000 <int-e> newsham: You can embed Prod (a -> b) (c -> d) into Either a c -> Either b d.
2023-12-10 01:20:06 +0000 <int-e> (But the latter has more arrows than the former)
2023-12-10 01:20:08 +0000 <shachaf> Oh man, does Haskell's Category support kinds other than * now? I thought you had to use wacky alternative classes.
2023-12-10 01:20:23 +0000emmanuelux(~emmanuelu@user/emmanuelux) (Ping timeout: 264 seconds)
2023-12-10 01:31:16 +0000cimento(CO2@gateway/vpn/protonvpn/cimento)
2023-12-10 01:35:46 +0000mhatta(~mhatta@www21123ui.sakura.ne.jp) (Quit: ZNC 1.8.2+deb3.1 - https://znc.in)
2023-12-10 01:36:19 +0000tomboy64(~tomboy64@user/tomboy64) (Ping timeout: 255 seconds)
2023-12-10 01:38:14 +0000mhatta(~mhatta@www21123ui.sakura.ne.jp)
2023-12-10 01:40:21 +0000 <ski> @kind Category
2023-12-10 01:40:22 +0000 <lambdabot> (k -> k -> *) -> Constraint
2023-12-10 01:41:11 +0000ski's use numbering, rather than primes
2023-12-10 01:41:19 +0000tomboy64(~tomboy64@user/tomboy64)
2023-12-10 01:42:21 +0000 <shachaf> I am behind the times.
2023-12-10 01:42:42 +0000 <geekosaur> how much of that is just the PolyKinds extension?
2023-12-10 01:46:45 +0000 <shachaf> Presumably most of it?
2023-12-10 01:46:49 +0000cimento(CO2@gateway/vpn/protonvpn/cimento) (Quit: WeeChat 4.1.2)
2023-12-10 01:46:49 +0000andreabedini(~andreabed@159.196.202.200) (Quit: andreabedini)
2023-12-10 01:47:00 +0000 <shachaf> @kind Functor
2023-12-10 01:47:01 +0000 <lambdabot> (* -> *) -> Constraint
2023-12-10 01:47:26 +0000 <shachaf> I guess you'll still need all sorts of fancy things to define the diagonal functor and so on.
2023-12-10 01:48:58 +0000sawilagar(~sawilagar@user/sawilagar) (Remote host closed the connection)
2023-12-10 01:49:19 +0000cimento(CO2@gateway/vpn/protonvpn/cimento)
2023-12-10 01:49:22 +0000sawilagar(~sawilagar@user/sawilagar)
2023-12-10 01:52:55 +0000 <newsham> I want to say something like "if k1 is a morphism, and k2 is a morphism, then (Prod k1 k2) is a morphism".
2023-12-10 01:53:11 +0000 <newsham> but failing to get there with the syntax i am trying to use
2023-12-10 01:53:30 +0000 <EvanR> that description seems to be missing the source and target of the morphism
2023-12-10 01:53:46 +0000 <EvanR> unless there's only 1 object
2023-12-10 01:54:02 +0000 <newsham> was trying to go with:
2023-12-10 01:54:02 +0000 <newsham> class Morph k where
2023-12-10 01:54:03 +0000 <newsham>     apply :: (a `k` b) -> a -> b
2023-12-10 01:54:14 +0000 <shachaf> newsham: Hmm, doesn't that work with the thing [Leary] was suggesting?
2023-12-10 01:54:34 +0000 <newsham> i was trying to use heavy gadtery here if possible.  but perhaps thats misguided
2023-12-10 01:54:45 +0000 <newsham> trying to avoid
2023-12-10 01:55:32 +0000 <ski> that `Morph' doesn't seem to make much sense, to me
2023-12-10 01:55:50 +0000 <newsham> yah probably that too :)
2023-12-10 01:56:08 +0000 <jackdk> newsham: https://hackage.haskell.org/package/categories-1.0.7/docs/Control-Category-Cartesian-Closed.html ?
2023-12-10 01:56:18 +0000 <shachaf> Yes, I'm not sure what that Morph is trying to be.
2023-12-10 01:56:55 +0000 <ski> i guess it's expressing `k' is (the morphism type of a) concrete category
2023-12-10 01:56:59 +0000 <newsham> jackdk: thank you. i'm trying to build this as an exercise.
2023-12-10 01:57:30 +0000 <ski> (being a category with an underlying/forgetful functor to `Set', which we approximate with `Hask' here)
2023-12-10 01:58:37 +0000 <newsham> was hoping that Morph would help me define a morphism on products which i could then use to more easily write out an instance of cat for products.
2023-12-10 01:59:04 +0000 <ski> i don't think it would help with that
2023-12-10 01:59:54 +0000 <newsham> but the latter is the real goal here.. i just want to write out that for Prod (a `k` a') (b `k` b') form morphisms in product category.
2023-12-10 02:01:19 +0000 <newsham> with this https://github.com/timnewsham/hask-cats/blob/main/src/Alg.hs
2023-12-10 02:02:43 +0000wice(~wice@176.254.244.83) (Ping timeout: 276 seconds)
2023-12-10 02:06:39 +0000 <ski> (g . f) x = g (f x)
2023-12-10 02:08:27 +0000 <haskellbridge> 13<d​xtr> How is "a `foo` b `bar` c" evaluated?
2023-12-10 02:08:28 +0000 <ski> [Leary]'s suggestion sounds relevant
2023-12-10 02:08:48 +0000 <haskellbridge> 13<d​xtr> How is ```a `foo` b `bar` c``` evaluated?
2023-12-10 02:09:10 +0000sawilagar(~sawilagar@user/sawilagar) (Ping timeout: 255 seconds)
2023-12-10 02:10:20 +0000 <ski> > let a `foo` b = (a,b); a `bar` b = (a,b) in 0 `foo` 1 `bar` 2
2023-12-10 02:10:21 +0000 <lambdabot> ((0,1),2)
2023-12-10 02:12:10 +0000 <EvanR> > let foo = (,); bar = (,) in a `foo` b `bar` c
2023-12-10 02:12:11 +0000 <lambdabot> ((a,b),c)
2023-12-10 02:12:50 +0000Unicorn_Princess(~Unicorn_P@user/Unicorn-Princess/x-3540542) (Remote host closed the connection)
2023-12-10 02:13:16 +0000 <EvanR> but this depends on the defined precedence of foo and bar right
2023-12-10 02:13:34 +0000 <EvanR> and fixity
2023-12-10 02:16:29 +0000 <ski> "An operator is either an operator symbol, such as + or $$, or is an ordinary identifier enclosed in grave accents (backquotes), such as `op`. For example, instead of writing the prefix application op x y, one can write the infix application x `op` y. If no fixity declaration is given for `op` then it defaults to highest precedence and left associativity (see Section 4.4.2)."
2023-12-10 02:16:35 +0000 <ski> <https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-240003.2>
2023-12-10 02:16:51 +0000 <ski> this means that, without a fixity declaration for `foo' and `bar', you'll effectively get
2023-12-10 02:16:59 +0000 <ski> infixl 9 `foo`,`bar`
2023-12-10 02:17:12 +0000 <ski> dxtr ^
2023-12-10 02:18:21 +0000 <haskellbridge> 13<d​xtr> Alright
2023-12-10 02:18:51 +0000 <newsham> where does the bridge comm with?
2023-12-10 02:19:38 +0000 <ski> newsham : you may even be able to use `Prod' at kind level, and `:*' at type level, for the product category, with `DataKinds'
2023-12-10 02:20:16 +0000 <newsham> you mean to make the product types more readable?
2023-12-10 02:21:52 +0000 <ski> more like reusing your `Prod' definition
2023-12-10 02:23:09 +0000 <geekosaur> newsham, #haskell-irc:matrix.org
2023-12-10 02:23:24 +0000 <newsham> not sure i follow. i know a little of data kinds (ie. put data defn of Nat into types), but not sure i know what you mean for using prod at kind level.
2023-12-10 02:23:29 +0000 <ski> (replacing the '(i0,i1) with i0 :* i1 that is)
2023-12-10 02:25:51 +0000 <ski> so that [Leary]'s `ProdCat' (i'd call it `ProdMor', probably), gets kind `(k -> k -> *) -> (k -> l -> *) -> Prod k l -> Prod k l -> *'
2023-12-10 02:25:58 +0000lane1(~lane@pool-98-113-180-17.nycmny.fios.verizon.net)
2023-12-10 02:26:31 +0000 <[Leary]> Blame `class Category`.
2023-12-10 02:26:54 +0000 <geekosaur> newsham, /whois haskellbridge gives more information, in particular a link to what channels it bridges to what Matrix rooms
2023-12-10 02:28:54 +0000 <newsham> guh is it possible to turn off emojis in libera's web chat?
2023-12-10 02:28:55 +0000lane(~lane@pool-98-113-180-17.nycmny.fios.verizon.net) (Ping timeout: 268 seconds)
2023-12-10 02:29:40 +0000 <geekosaur> I don't think so
2023-12-10 02:29:52 +0000 <newsham> found it. upper left gear.
2023-12-10 02:30:01 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 02:30:49 +0000 <newsham> and yet i still see the emojis for messages above.   test :* this.
2023-12-10 02:31:09 +0000 <newsham> i guess its not retroactive on prev msgs
2023-12-10 02:31:21 +0000 <geekosaur> you might prefer checking the log (see the /topic)
2023-12-10 02:33:07 +0000sagax(~sagax_nb@user/sagax)
2023-12-10 02:34:47 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 264 seconds)
2023-12-10 02:36:50 +0000 <ski> newsham : it turns off auto-replacing smileys with emoji, i think, but doesn't affect incoming messages
2023-12-10 02:37:30 +0000 <ski> (hm, or maybe it was the emoji selection button it disabled .. some times since i was on Kiwi)
2023-12-10 02:38:20 +0000jmdaemon(~jmdaemon@user/jmdaemon)
2023-12-10 02:44:53 +0000td_(~td@i5387091B.versanet.de) (Ping timeout: 240 seconds)
2023-12-10 02:47:34 +0000mechap(~mechap@user/mechap) (Ping timeout: 276 seconds)
2023-12-10 02:53:15 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 02:57:01 +0000 <newsham> in the category constructed by coproducts, are the morphisms also constructed as coproducts?
2023-12-10 02:58:31 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 268 seconds)
2023-12-10 03:02:05 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 03:04:47 +0000igemnace(~ian@user/igemnace)
2023-12-10 03:07:56 +0000igemnace_(~ian@user/igemnace)
2023-12-10 03:09:12 +0000igemnace1(~ian@user/igemnace)
2023-12-10 03:10:11 +0000igemnace1(~ian@user/igemnace) (Remote host closed the connection)
2023-12-10 03:10:14 +0000igemnace(~ian@user/igemnace) (Ping timeout: 268 seconds)
2023-12-10 03:10:54 +0000igemnace(~ian@user/igemnace)
2023-12-10 03:11:26 +0000td_(~td@i5387091B.versanet.de)
2023-12-10 03:12:10 +0000igemnace_(~ian@user/igemnace) (Ping timeout: 255 seconds)
2023-12-10 03:12:21 +0000igemnace_(~ian@user/igemnace)
2023-12-10 03:12:52 +0000thegeekinside(~thegeekin@177.245.195.141)
2023-12-10 03:14:52 +0000Square(~Square@user/square) (Ping timeout: 276 seconds)
2023-12-10 03:15:25 +0000igemnace(~ian@user/igemnace) (Ping timeout: 256 seconds)
2023-12-10 03:20:25 +0000lottaquestions(~nick@2607:fa49:503d:b200:8455:7551:a8b5:adb1)
2023-12-10 03:29:53 +0000lane1(~lane@pool-98-113-180-17.nycmny.fios.verizon.net) (Quit: WeeChat 4.1.2)
2023-12-10 03:35:38 +0000 <ski> newsham : hm, which category ?
2023-12-10 03:36:03 +0000 <ski> the one int-e sketched ?
2023-12-10 03:41:39 +0000 <int-e> :t id +++ id
2023-12-10 03:41:40 +0000 <lambdabot> Either b b' -> Either b b'
2023-12-10 03:41:44 +0000tremon(~tremon@83.80.159.219) (Quit: getting boxed in)
2023-12-10 03:42:14 +0000 <int-e> :t either Right Left -- something extra
2023-12-10 03:42:15 +0000 <lambdabot> Either b a -> Either a b
2023-12-10 03:42:37 +0000td_(~td@i5387091B.versanet.de) (Ping timeout: 256 seconds)
2023-12-10 03:42:44 +0000 <newsham> how does Either (a' -> a'') (b' -> b'') compose with (Either (a -> a') (b -> b') ?
2023-12-10 03:43:10 +0000 <newsham> given that you might have Left (g :: a -> a'') and Right (f :: b -> b')
2023-12-10 03:43:19 +0000 <int-e> newsham: It doesn't
2023-12-10 03:43:35 +0000 <newsham> so what is the proper type for composition?  do the left and right have to be more compat?
2023-12-10 03:44:02 +0000 <int-e> @djinn Either (a -> b) (a' -> b') -> Either (b -> c) (b' -> c') -> Either (a -> c) (a' -> c')
2023-12-10 03:44:02 +0000 <lambdabot> -- f cannot be realized.
2023-12-10 03:44:05 +0000td_(~td@i53870907.versanet.de)
2023-12-10 03:44:22 +0000 <ski> newsham : is that supposed to be ordinary `Either' in Haskell ?
2023-12-10 03:44:45 +0000 <ski> (or some data constructor for a datakind, maybe ?)
2023-12-10 03:44:47 +0000 <int-e> "You can embed Prod (a -> b) (c -> d) into Either a c -> Either b d."
2023-12-10 03:45:15 +0000 <int-e> In which case the composition you want is just function composition. But there are extra functions in there like that `either Right Left` thing.
2023-12-10 03:45:28 +0000 <int-e> So it's really just an embedding.
2023-12-10 03:45:55 +0000 <int-e> But it would work with the existing `Category` class.
2023-12-10 03:47:09 +0000 <int-e> :t (+++)
2023-12-10 03:47:10 +0000 <lambdabot> ArrowChoice a => a b c -> a b' c' -> a (Either b b') (Either c c')
2023-12-10 03:47:12 +0000 <ski> (note that the `Prod' in `Prod (a -> b) (c -> d)' doesn't really have to do with product categories)
2023-12-10 03:47:16 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 03:47:25 +0000 <newsham> bartosz' cat theory for programmers talks about constructing a category from a prod of two categories, and shows the construction.  he also mentions constructing a category from a coprod of two categories but does not go into details.  i'm trying to figure out what it means.
2023-12-10 03:47:47 +0000 <int-e> ski: yeah good point
2023-12-10 03:47:51 +0000 <ski> the coproduct category is more involved, iirc
2023-12-10 03:48:17 +0000 <newsham> ok, maybe i should wait till later in the series to try to figure this out then.
2023-12-10 03:48:51 +0000 <int-e> (a -> b, c -> d) captures fewer functions than (a,c) -> (b,d).
2023-12-10 03:48:53 +0000 <int-e> :t (***)
2023-12-10 03:48:54 +0000 <ski> i like the search/optimization analogy that Bartosz uses for limits and colimits
2023-12-10 03:48:55 +0000 <lambdabot> Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
2023-12-10 03:49:09 +0000 <int-e> (another embedding)
2023-12-10 03:49:44 +0000 <ski> .. a philosophy paper i read, that talks about category theory, and Plato's theory of forms, uses the same analogy more or less, iirc
2023-12-10 03:51:09 +0000 <ski> "Category Theory and Concrete Universals" by David P. Ellerman in 1998-05 at <https://www.ellerman.org/wp-content/uploads/2012/12/Erkenntnis-Concrete-Universals.CV_.pdf> -- although, iirc, some of the formulae in the paper were unfortunately somewhat confused
2023-12-10 03:53:14 +0000finn_elija(~finn_elij@user/finn-elija/x-0085643)
2023-12-10 03:53:14 +0000FinnElija(~finn_elij@user/finn-elija/x-0085643) (Killed (NickServ (Forcing logout FinnElija -> finn_elija)))
2023-12-10 03:53:14 +0000finn_elijaFinnElija
2023-12-10 03:57:19 +0000mosul(~mosul@user/mosul) (Read error: Connection reset by peer)
2023-12-10 04:02:35 +0000mosul(~mosul@user/mosul)
2023-12-10 04:03:01 +0000drdo(~drdo@bl14-14-49.dsl.telepac.pt) (Ping timeout: 255 seconds)
2023-12-10 04:13:04 +0000szkl(uid110435@id-110435.uxbridge.irccloud.com)
2023-12-10 04:19:40 +0000jargon(~jargon@32.sub-174-238-226.myvzw.com) (Remote host closed the connection)
2023-12-10 04:24:55 +0000 <ski> right, on page eight, it says "As a universality condition, this is: ⟨f,g⟩ uniquely factors through ⟨π₁,π₂⟩ iff for some x, f: x ⟶ a and g: x ⟶ b.", but it ought to say "As a universality condition, this is: ⟨f,g⟩ uniquely factors through ⟨π₁,π₂⟩ iff for some unique h: x ⟶ a × b, f = π₁ ∘ h and g = π₂ ∘ h."
2023-12-10 04:25:04 +0000 <ski> also, on page thirteen, when it talks about union, it ought to use the union symbol ⌜∪⌝, not the intersection symbol ⌜∩⌝, iow ought to say ⌜for all x, x ≥ a ∪ b iff a ≤ x & b ≤ x⌝, rather than ⌜for all x, x ≥ a ∩ b iff a ≤ x & b ≤ x⌝. and on page fourteen, it ought to say ⌜⋂{x ∣ a ≤ x & b ≤ x} = a ∪ b⌝ rather than ⌜⋂{x ∣ a ≤ x & b ≤ x} = a ∩ b⌝
2023-12-10 04:26:45 +0000araujo(~araujo@45.131.194.89)
2023-12-10 04:26:50 +0000 <araujo> howdy :)
2023-12-10 04:28:01 +0000 <ski> oy
2023-12-10 04:28:34 +0000pretty_dumm_guy(trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655) (Quit: WeeChat 3.5)
2023-12-10 04:31:43 +0000araujo(~araujo@45.131.194.89) (Remote host closed the connection)
2023-12-10 04:32:36 +0000araujo(~araujo@45.131.194.89)
2023-12-10 04:36:00 +0000 <araujo> :)
2023-12-10 04:41:04 +0000aforemny(~aforemny@2001:9e8:6cf6:8a00:1295:f852:5f8f:52b5)
2023-12-10 04:42:35 +0000aforemny_(~aforemny@i59F516ED.versanet.de) (Ping timeout: 264 seconds)
2023-12-10 04:44:42 +0000igemnace_(~ian@user/igemnace) (Quit: WeeChat 4.1.2)
2023-12-10 04:45:15 +0000thegeekinside(~thegeekin@177.245.195.141) (Ping timeout: 252 seconds)
2023-12-10 04:45:18 +0000lane(~lane@pool-98-113-180-17.nycmny.fios.verizon.net)
2023-12-10 04:45:34 +0000sagax(~sagax_nb@user/sagax) (Remote host closed the connection)
2023-12-10 04:46:07 +0000lane(~lane@pool-98-113-180-17.nycmny.fios.verizon.net) (Remote host closed the connection)
2023-12-10 04:46:31 +0000igemnace(~ian@user/igemnace)
2023-12-10 04:47:54 +0000araujo(~araujo@45.131.194.89) (Quit: Leaving)
2023-12-10 04:48:30 +0000araujo(~araujo@45.131.194.89)
2023-12-10 04:48:47 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 256 seconds)
2023-12-10 04:51:52 +0000araujo(~araujo@45.131.194.89) (Client Quit)
2023-12-10 04:52:15 +0000araujo(~araujo@45.131.194.89)
2023-12-10 05:00:37 +0000DerDummNemetzkii(~John_Ivan@user/john-ivan/x-1515935) (Ping timeout: 255 seconds)
2023-12-10 05:09:12 +0000hgolden_(~hgolden@2603-8000-9d00-3ed1-dd4f-298a-9c49-a0ed.res6.spectrum.com) (Remote host closed the connection)
2023-12-10 05:09:58 +0000trev(~trev@user/trev)
2023-12-10 05:10:39 +0000trev(~trev@user/trev) (Read error: Connection reset by peer)
2023-12-10 05:11:20 +0000hgolden(~hgolden@2603-8000-9d00-3ed1-dd4f-298a-9c49-a0ed.res6.spectrum.com)
2023-12-10 05:11:57 +0000trev(~trev@user/trev)
2023-12-10 05:22:45 +0000azimut(~azimut@gateway/tor-sasl/azimut) (Remote host closed the connection)
2023-12-10 05:25:58 +0000azimut(~azimut@gateway/tor-sasl/azimut)
2023-12-10 05:27:52 +0000azimut(~azimut@gateway/tor-sasl/azimut) (Remote host closed the connection)
2023-12-10 05:28:11 +0000azimut(~azimut@gateway/tor-sasl/azimut)
2023-12-10 05:32:08 +0000takuan(~takuan@178-116-218-225.access.telenet.be)
2023-12-10 05:33:05 +0000Pozyomka_(~pyon@user/pyon)
2023-12-10 05:33:07 +0000Pozyomka(~pyon@user/pyon) (Ping timeout: 256 seconds)
2023-12-10 05:35:25 +0000igemnace(~ian@user/igemnace) (Remote host closed the connection)
2023-12-10 05:36:10 +0000igemnace(~ian@user/igemnace)
2023-12-10 05:45:52 +0000igemnace(~ian@user/igemnace) (Remote host closed the connection)
2023-12-10 05:46:36 +0000igemnace(~ian@user/igemnace)
2023-12-10 05:52:24 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com)
2023-12-10 06:04:29 +0000araujo(~araujo@45.131.194.89) (Quit: Leaving)
2023-12-10 06:06:48 +0000araujo(~araujo@216.73.163.11)
2023-12-10 06:08:42 +0000ec(~ec@gateway/tor-sasl/ec) (Remote host closed the connection)
2023-12-10 07:06:53 +0000sagax(~sagax_nb@user/sagax)
2023-12-10 07:20:13 +0000notzmv(~zmv@user/notzmv) (Ping timeout: 256 seconds)
2023-12-10 07:22:05 +0000skyres(~skyres@176.254.244.83)
2023-12-10 07:22:45 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 07:23:16 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 255 seconds)
2023-12-10 07:29:01 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 07:32:51 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 07:33:10 +0000smalltalkman(uid545680@id-545680.hampstead.irccloud.com) (Quit: Connection closed for inactivity)
2023-12-10 07:36:36 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 245 seconds)
2023-12-10 07:43:26 +0000cwdar^(~cd@c-98-242-74-66.hsd1.ga.comcast.net)
2023-12-10 07:44:14 +0000acidjnk_new(~acidjnk@p200300d6e72b93299103c78233b0ca81.dip0.t-ipconnect.de)
2023-12-10 07:45:54 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 07:46:33 +0000igemnace(~ian@user/igemnace) (Quit: WeeChat 4.1.2)
2023-12-10 07:48:45 +0000m1dnight(~christoph@78-22-4-67.access.telenet.be) (Quit: WeeChat 4.1.1)
2023-12-10 07:50:46 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 260 seconds)
2023-12-10 07:51:41 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com) (Ping timeout: 252 seconds)
2023-12-10 08:04:18 +0000bilegeek(~bilegeek@2600:1008:b065:6c8a:2877:790c:5cda:9f45) (Quit: Leaving)
2023-12-10 08:05:17 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 08:06:00 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 08:23:29 +0000m1dnight(~christoph@78-22-4-67.access.telenet.be)
2023-12-10 08:25:52 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 256 seconds)
2023-12-10 08:39:52 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 08:44:20 +0000fendor(~fendor@2a02:8388:1605:d100:267b:1353:13d7:4f0c)
2023-12-10 08:45:42 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 08:46:11 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 08:48:07 +0000phma(~phma@2001:5b0:2143:b148:7b24:e989:5355:982f) (Read error: Connection reset by peer)
2023-12-10 08:51:15 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 268 seconds)
2023-12-10 08:56:02 +0000waleee(~waleee@h-176-10-144-38.NA.cust.bahnhof.se)
2023-12-10 08:57:52 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 09:00:14 +0000phma(phma@2001:5b0:215d:95d8:ddad:50d4:4c93:5f61)
2023-12-10 09:01:20 +0000Tuplanolla(~Tuplanoll@91-159-68-236.elisa-laajakaista.fi)
2023-12-10 09:02:08 +0000arkoinad(~abhinav@c-67-169-139-16.hsd1.ca.comcast.net) (Ping timeout: 256 seconds)
2023-12-10 09:02:10 +0000tzh(~tzh@c-71-193-181-0.hsd1.or.comcast.net) (Quit: zzz)
2023-12-10 09:03:53 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 09:06:28 +0000idgaen(~idgaen@2a01:e0a:498:fd50:fcc6:bb5d:489a:ce8c)
2023-12-10 09:12:05 +0000sagax(~sagax_nb@user/sagax) (Excess Flood)
2023-12-10 09:15:57 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 09:16:10 +0000_ht(~Thunderbi@28-52-174-82.ftth.glasoperator.nl)
2023-12-10 09:19:45 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:1fe:ac5a:8c23:9cce) (Remote host closed the connection)
2023-12-10 09:24:06 +0000jmdaemon(~jmdaemon@user/jmdaemon) (Ping timeout: 260 seconds)
2023-12-10 09:26:37 +0000phma(phma@2001:5b0:215d:95d8:ddad:50d4:4c93:5f61) (Read error: Connection reset by peer)
2023-12-10 09:30:52 +0000phma(~phma@2001:5b0:211c:d608:d6b3:ddaf:3415:a75)
2023-12-10 09:30:58 +0000notzmv(~zmv@user/notzmv)
2023-12-10 09:35:02 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Read error: Connection reset by peer)
2023-12-10 09:38:59 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 264 seconds)
2023-12-10 09:43:21 +0000rosco(~rosco@175.136.152.56)
2023-12-10 09:43:37 +0000coot(~coot@89-69-206-216.dynamic.chello.pl)
2023-12-10 09:48:20 +0000gmg(~user@user/gehmehgeh)
2023-12-10 09:50:41 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 09:54:48 +0000econo_(uid147250@id-147250.tinside.irccloud.com) (Quit: Connection closed for inactivity)
2023-12-10 09:56:23 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 264 seconds)
2023-12-10 09:58:45 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:d128:ce35:54e1:65e2)
2023-12-10 10:09:58 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 10:18:28 +0000Lord_of_Life_(~Lord@user/lord-of-life/x-2819915)
2023-12-10 10:19:10 +0000Lord_of_Life(~Lord@user/lord-of-life/x-2819915) (Ping timeout: 260 seconds)
2023-12-10 10:21:24 +0000Lord_of_Life_Lord_of_Life
2023-12-10 10:22:06 +0000pretty_dumm_guy(trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655)
2023-12-10 10:29:58 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 256 seconds)
2023-12-10 10:32:58 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 10:33:38 +0000target_i(~target_i@217.175.14.39)
2023-12-10 10:38:39 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 260 seconds)
2023-12-10 10:49:15 +0000Sgeo(~Sgeo@user/sgeo) (Read error: Connection reset by peer)
2023-12-10 10:51:47 +0000sawilagar(~sawilagar@user/sawilagar)
2023-12-10 10:52:14 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 10:57:02 +0000mikess(~sam@user/mikess) (Ping timeout: 252 seconds)
2023-12-10 11:05:25 +0000Katty(~osboxes@185.98.164.21)
2023-12-10 11:07:56 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 256 seconds)
2023-12-10 11:09:57 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 11:10:14 +0000xff0x(~xff0x@ai085147.d.east.v6connect.net) (Ping timeout: 252 seconds)
2023-12-10 11:12:05 +0000xff0x(~xff0x@178.255.149.135)
2023-12-10 11:14:53 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 240 seconds)
2023-12-10 11:16:23 +0000Katty(~osboxes@185.98.164.21) (Quit: Konversation terminated!)
2023-12-10 11:20:09 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 11:21:17 +0000billchenchina(~billchenc@103.152.35.21)
2023-12-10 11:22:23 +0000machinedgod(~machinedg@93-136-52-133.adsl.net.t-com.hr)
2023-12-10 11:22:27 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
2023-12-10 11:23:04 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2023-12-10 11:30:10 +0000rosco(~rosco@175.136.152.56) (Ping timeout: 276 seconds)
2023-12-10 11:32:16 +0000Joao003(~Joao003@190.108.99.32)
2023-12-10 11:36:49 +0000xff0x(~xff0x@178.255.149.135) (Ping timeout: 268 seconds)
2023-12-10 11:38:44 +0000xff0x(~xff0x@ai085147.d.east.v6connect.net)
2023-12-10 11:39:17 +0000rosco(~rosco@175.136.152.56)
2023-12-10 11:40:22 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 260 seconds)
2023-12-10 11:53:40 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 11:55:09 +0000alexherbo2(~alexherbo@2a02-8440-3141-30c9-9c1f-1fa2-2dd0-8b5b.rev.sfr.net)
2023-12-10 11:56:04 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 12:00:04 +0000[_](~itchyjunk@user/itchyjunk/x-7353470) (Ping timeout: 276 seconds)
2023-12-10 12:01:11 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 245 seconds)
2023-12-10 12:01:45 +0000mrmr15533(~mrmr@user/mrmr) (Quit: Bye, See ya later!)
2023-12-10 12:05:05 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470) (Remote host closed the connection)
2023-12-10 12:06:54 +0000mrmr15533(~mrmr@user/mrmr)
2023-12-10 12:09:25 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 12:10:19 +0000mniip_mniip
2023-12-10 12:14:19 +0000vgtw(~vgtw@user/vgtw) (Ping timeout: 256 seconds)
2023-12-10 12:15:35 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 12:34:19 +0000target_i(~target_i@217.175.14.39) (Quit: leaving)
2023-12-10 12:34:46 +0000billchenchina(~billchenc@103.152.35.21) (Remote host closed the connection)
2023-12-10 12:34:57 +0000billchenchina(~billchenc@2a0d:2580:ff0c:1:e3c9:c52b:a429:5bfe)
2023-12-10 12:37:39 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 260 seconds)
2023-12-10 12:37:51 +0000not_reserved(~not_reser@185.216.201.100) (Quit: Client closed)
2023-12-10 12:41:42 +0000Ashkan(~Ashkan@147.161.173.72)
2023-12-10 12:42:03 +0000jtomas(~jtomas@90.162.208.36)
2023-12-10 12:46:13 +0000foul_owl(~kerry@157.97.134.165) (Ping timeout: 276 seconds)
2023-12-10 12:47:00 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 12:47:42 +0000 <Joao003> me waiting for someone to ask something:
2023-12-10 12:48:10 +0000 <Ashkan> Hi folks. Got a question regarding a datatype + possibly a monad to model a search across a Foldable.
2023-12-10 12:48:11 +0000 <Ashkan> I have a Foldable (a `Vector a` to be exact) and I need to run an `f :: a -> ??? s b ` on it and exit when the first `a` is found such that `f` produces a result that satisfies a certain condition. Not sure how to model this though. Lots of dark spots in my head:D
2023-12-10 12:50:11 +0000 <[Leary]> :t find
2023-12-10 12:50:12 +0000 <lambdabot> Foldable t => (a -> Bool) -> t a -> Maybe a
2023-12-10 12:50:14 +0000 <Ashkan> `f` is "state-full" in `s`, meaning there is an initial `s0` and then as `f` progresses on the input Foldable, it updates the `s` until eventually one `a` arrives that results in the `??? s b` to "short-circuit" (using monad terminology) and exit
2023-12-10 12:50:54 +0000 <Rembane> :t First -- along with foldMap could perhaps also help you, if you want a Monoid solution to this problem.
2023-12-10 12:50:55 +0000 <lambdabot> Maybe a -> First a
2023-12-10 12:51:08 +0000 <Rembane> Hm... wrong First.
2023-12-10 12:51:29 +0000 <Ashkan> so far I think closest is `foldlM`
2023-12-10 12:51:32 +0000 <Ashkan> :t foldlM
2023-12-10 12:51:33 +0000 <lambdabot> (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
2023-12-10 12:51:56 +0000 <Rembane> Ashkan: But I think [Leary]'s solution is the simplest one.
2023-12-10 12:52:03 +0000 <Joao003> yeah
2023-12-10 12:52:57 +0000Aworks(~Aworks@2a09:bac2:c63:3cd::61:26e)
2023-12-10 12:53:04 +0000 <Joao003> but the tricky thing is extracting the result from the `Maybe a' that `find' produces
2023-12-10 12:53:10 +0000 <Ashkan> Please notice `f :: b -> a -> m b` which is actually closest to my needs but not quite. Because (1) my action is monadic (it's an `IO` in fact) and (2) I don't want the matching `a` itself, I want the result of the operation
2023-12-10 12:53:34 +0000 <Joao003> oh ok
2023-12-10 12:54:20 +0000 <Joao003> you could use something like a `Maybe' for `m'
2023-12-10 12:55:11 +0000 <Aworks> upi
2023-12-10 12:55:34 +0000 <Aworks> Buddies have build an full Windows with husk
2023-12-10 12:55:49 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 255 seconds)
2023-12-10 12:56:10 +0000 <Ashkan> Okay let me put this way then:
2023-12-10 12:56:10 +0000 <Ashkan> I'm doing a Vulkan thingie and I have a list of devices `Vector Vk.Device` . Now I need to do some magic `IO` thing on each device to extract some `b` out (`doMagic :: Device -> IO b`) and exit with the first `b` that passes a certain check. I don't want the device itself, I want the `b`.
2023-12-10 12:57:09 +0000 <Joao003> OK, I understand.
2023-12-10 12:59:02 +0000 <Joao003> So you have a list of `Device's, and want do do some `IO' thing to each one, checking for a condition until you find the first one that passes. Am I correct?
2023-12-10 12:59:12 +0000 <Ashkan> Joao003 `Maybe b` doesn't have the `IO` in it. If I make it `MaybeT IO b` then it will short-circut on `Nothing` which means I stop at the right spot but then I get nothing out. I was thinking `ExceptT IO found state` and model "success" (in `found`) as left and "contiunue with the search" (in `state`) as right. But I'm not sure if this is
2023-12-10 12:59:12 +0000 <Ashkan> idiomatic ...
2023-12-10 12:59:55 +0000foul_owl(~kerry@174-21-66-189.tukw.qwest.net)
2023-12-10 13:00:03 +0000aruns(~aruns@user/aruns)
2023-12-10 13:00:09 +0000 <Ashkan> Joao003 yes but : the check involves an accumulating state. So first device the state is `s0` but next device the state has changed. the `f` updates the state
2023-12-10 13:00:21 +0000 <Joao003> Oh.
2023-12-10 13:00:48 +0000 <Ashkan> Also I don't want the device itself, I want the output of `Device -> IO b` (the `b`)
2023-12-10 13:00:54 +0000 <Joao003> I KNOW.
2023-12-10 13:01:26 +0000 <Joao003> So you want a function kinda like a fold and `find', right?
2023-12-10 13:02:15 +0000 <Ashkan> like this `f: Device -> ExceptT IO b s`. `IO Left b` means we found it, exit with the `Left b`, `IO Right s` means "continue with the next device and new state `s`"
2023-12-10 13:02:37 +0000 <Joao003> Ok.
2023-12-10 13:04:02 +0000 <Ashkan> Joao003 Yes. I'm "interpreting" (maybe I'm wrong ?) from `foldlM` that choosing the right `m` with the short-circuting behaviour would in effect achieve what I want. But the only monad I can think of that short-circuts with a value AND can do `IO` is `ExceptT`
2023-12-10 13:04:35 +0000 <Joao003> So a `foldl' which after each function application checks the result for something and prematurely stops if it finds the right one?
2023-12-10 13:06:13 +0000 <Joao003> BTW, what is an `ExceptT'?
2023-12-10 13:06:56 +0000alexherbo2(~alexherbo@2a02-8440-3141-30c9-9c1f-1fa2-2dd0-8b5b.rev.sfr.net) (Ping timeout: 250 seconds)
2023-12-10 13:07:18 +0000 <Ashkan> Joao003 actually if it was *not* monadic (the need for `IO`) then a `foldr` would be what I want because I needed the `f` to be lazy in the accumulator
2023-12-10 13:07:24 +0000 <Ashkan> :t ExceptT
2023-12-10 13:07:25 +0000 <lambdabot> m (Either e a) -> ExceptT e m a
2023-12-10 13:07:40 +0000 <Ashkan> It's the new EitherT
2023-12-10 13:07:43 +0000 <Ashkan> :t EitherT
2023-12-10 13:07:44 +0000 <lambdabot> error:
2023-12-10 13:07:44 +0000 <lambdabot> • Data constructor not in scope: EitherT
2023-12-10 13:07:44 +0000 <lambdabot> • Perhaps you meant variable ‘either’ (imported from Data.Either)
2023-12-10 13:07:55 +0000 <Ashkan> They just removed the EitherT I guess
2023-12-10 13:08:27 +0000 <[Leary]> :t \p -> traverse_ (when <$> p <*> throwE)
2023-12-10 13:08:28 +0000 <lambdabot> (Foldable t, Monad m) => (a -> Bool) -> t a -> ExceptT a m ()
2023-12-10 13:08:36 +0000 <Joao003> :t Either
2023-12-10 13:08:37 +0000 <lambdabot> error:
2023-12-10 13:08:37 +0000 <lambdabot> • Data constructor not in scope: Either
2023-12-10 13:08:37 +0000 <lambdabot> • Perhaps you meant variable ‘either’ (imported from Data.Either)
2023-12-10 13:08:45 +0000 <Ashkan> `ExceptT b IO s` = can model two states: continue with `s` or exit with `b`
2023-12-10 13:08:48 +0000 <[Leary]> :t \f p -> traverse_ (when <$> p <*> throwE <=< lift . f)
2023-12-10 13:08:48 +0000 <lambdabot> (Foldable t, Monad m) => (a -> m b) -> (b -> Bool) -> t a -> ExceptT b m ()
2023-12-10 13:08:57 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 13:09:28 +0000 <[Leary]> :t \f p -> fmap (either Just (const Nothing)) . runExceptT . traverse_ (when <$> p <*> throwE <=< lift . f)
2023-12-10 13:09:29 +0000 <lambdabot> (Foldable t, Monad f) => (a -> f b) -> (b -> Bool) -> t a -> f (Maybe b)
2023-12-10 13:09:31 +0000 <Ashkan> This is very close actually. Let me see ...
2023-12-10 13:09:38 +0000 <[Leary]> Looks about right.
2023-12-10 13:09:43 +0000 <Joao003> So basically `ExceptT b IO s' is `IO (Either b s)', right?
2023-12-10 13:10:26 +0000 <Ashkan> Joao003 yes. Not sure what call it `ExceptT` and confuse the hell out of everyone. But yes. Basically an `EitherT`
2023-12-10 13:11:02 +0000 <Joao003> Yeah, Haskell naming is pretty confusing. Like, who named `return'/`pure'?
2023-12-10 13:12:05 +0000alexherbo2(~alexherbo@2a02-8440-3140-ec03-d472-b551-beb0-2cfa.rev.sfr.net)
2023-12-10 13:12:37 +0000 <Ashkan> `IO (Either b s)` has the right data structure to model my two paths (continue the chain with a new state value or exit with a value) *but* it does NOT have the right short-circuting because the monad then is `IO`, `ExceptT` will exit if it's value is `IO (Left b)` but `IO` will *not*
2023-12-10 13:12:56 +0000 <Joao003> Hmm.
2023-12-10 13:13:09 +0000 <Ashkan> actually that point is the key here
2023-12-10 13:13:20 +0000 <Ashkan> Think about it. Maybe I'm woring.
2023-12-10 13:14:33 +0000 <Ashkan> I want the `IO (Left b)` to stop the search. I want the `IO (Right s)` to continue the search with the new `s`. `IO (Either b s)` will not do that but `ExceptT s IO b` will do that.
2023-12-10 13:14:54 +0000 <Joao003> This is kinda off-topic, but GHC quotes with `' instead of ``.
2023-12-10 13:15:08 +0000 <Ashkan> and I'm using a `fold*` variant to model the "search"
2023-12-10 13:16:18 +0000 <Joao003> Can you explain why the `ExceptT' is important?
2023-12-10 13:17:58 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Read error: Connection reset by peer)
2023-12-10 13:18:03 +0000 <Ashkan> Because `IO (Left b)` will not exit, because monad is `IO` and `IO` exits on io exceptions. `IO Left x` continues the chain with a `Left x`
2023-12-10 13:18:57 +0000 <Joao003> Ok.
2023-12-10 13:19:11 +0000 <Ashkan> I want a monad that exits when it holds a `Left b`. `ExceptT` does that. But if I can find another monad that can do `IO` *and* can model two outcomes (continue with `s` or exit with `b`) , that would also do.
2023-12-10 13:20:06 +0000 <Joao003> What do you mean by "exit"?
2023-12-10 13:20:17 +0000 <Ashkan> [Leary] since you came up with the best signature, would you please comment on my last message ? specially do you know of a way I can get the behaviour I want other than ExceptT ? thanks
2023-12-10 13:21:06 +0000 <[Leary]> It would also work to embed the `b` in an IO exception and catch it on the outside, but that would involve a little more boilerplate. I'm sure you could do it with ContT too, but there's no reason to go there.
2023-12-10 13:21:12 +0000 <Ashkan> Joao003 short-circut the monadic chain created by `fold**`. e.g. `Maybe` will exit on `Nothing`. `Either` will exit on `Left`. `IO` will exit if an exception is thrown
2023-12-10 13:21:55 +0000 <Ashkan> Joao003 The essence of monad is when it continues with the flatMap and when it short-circuts
2023-12-10 13:22:24 +0000szkl(uid110435@id-110435.uxbridge.irccloud.com) (Quit: Connection closed for inactivity)
2023-12-10 13:22:37 +0000 <Joao003> I think the monads conflict what you want
2023-12-10 13:23:22 +0000 <Ashkan> [Leary] `IO` with an exception is exactly what I thought at first but then it sounds way far off to model a "found it" outcome with an IO exception. Didn't think about `ContT` though ...
2023-12-10 13:24:34 +0000cwdar^(~cd@c-98-242-74-66.hsd1.ga.comcast.net) (Remote host closed the connection)
2023-12-10 13:25:33 +0000vgtw(~vgtw@user/vgtw)
2023-12-10 13:25:51 +0000 <Ashkan> wdyt of introducing my own monad like `data Search m b s = m Found b | m Continue s` with the proper `>>=` ? too much ?
2023-12-10 13:26:22 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Ping timeout: 246 seconds)
2023-12-10 13:26:31 +0000 <Joao003> @hoogle ContT
2023-12-10 13:26:31 +0000 <lambdabot> Control.Monad.Trans.Cont newtype ContT r m a
2023-12-10 13:26:31 +0000 <lambdabot> Control.Monad.Trans.Cont ContT :: ((a -> m r) -> m r) -> ContT r m a
2023-12-10 13:26:31 +0000 <lambdabot> Control.Monad.Cont newtype ContT (r :: k) (m :: k -> *) a
2023-12-10 13:26:32 +0000euleritian(~euleritia@dynamic-046-114-204-242.46.114.pool.telefonica.de)
2023-12-10 13:26:32 +0000 <Ashkan> Joao003 Could be. Why do you say ?
2023-12-10 13:27:39 +0000alexherbo2(~alexherbo@2a02-8440-3140-ec03-d472-b551-beb0-2cfa.rev.sfr.net) (Remote host closed the connection)
2023-12-10 13:27:54 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 256 seconds)
2023-12-10 13:28:00 +0000 <Joao003> Here is some docs of `ContT' from Hackage: "The continuation monad transformer. Can be used to add continuation handling to any type constructor: the Monad instance and most of the operations do not require m to be a monad."
2023-12-10 13:28:52 +0000alexherbo2(~alexherbo@54.149.22.93.rev.sfr.net)
2023-12-10 13:29:05 +0000 <Joao003> Ashkan: I think you can make a monad on your own for this.
2023-12-10 13:34:02 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 13:40:12 +0000 <[Leary]> Ashkan: I definitely wouldn't bother writing `Search` if it's doing exactly the same thing as ExceptT. At most, I'd consider renaming/wrapping some of the ExceptT interface for clarity.
2023-12-10 13:40:20 +0000 <ski> Ashkan : "I was thinking `ExceptT IO found state` and model \"success\" (in `found`) as left and \"contiunue with the search\" (in `state`) as right. But I'm not sure if this is idiomatic ..." -- sounds fine, to me
2023-12-10 13:40:25 +0000 <ski> @unmtl ExceptT b (StateT s IO) a
2023-12-10 13:40:25 +0000 <lambdabot> s -> IO (Either b a, s)
2023-12-10 13:40:29 +0000 <ski> f :: Device -> ExceptT b (StateT s IO) ()
2023-12-10 13:40:41 +0000 <ski> so you can use `traverse_ f'
2023-12-10 13:41:13 +0000mechap(~mechap@user/mechap)
2023-12-10 13:41:48 +0000 <ski> ah, i see [Leary] was on this track already
2023-12-10 13:42:49 +0000 <ski> or, if you don't want a result `s' in case you find a matching `b', use `StateT s (ExceptT e IO)' instead
2023-12-10 13:43:23 +0000 <ski> (i was thinking you wanted the last `s', regardless, but perhaps you don't)
2023-12-10 13:44:04 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 276 seconds)
2023-12-10 13:45:44 +0000drdo(~drdo@bl14-14-49.dsl.telepac.pt)
2023-12-10 13:46:02 +0000 <ski> (er, s/ExceptT e/ExceptT b/)
2023-12-10 13:47:41 +0000 <Ashkan> ski hmm ... nice.
2023-12-10 13:49:46 +0000 <Ashkan> I want to the first `s` that matches a predicate. The `s` changes while I'm running over the list of devices. So you are saying instead of seeing it as a fold over elements, see it has a state running on them via traverse ? novel +|1
2023-12-10 13:49:55 +0000 <Ashkan> didn't think of it that way
2023-12-10 13:50:41 +0000 <Ashkan> (yeah, I want the "last" s, correct)
2023-12-10 13:52:12 +0000 <[Leary]> @src traverse_
2023-12-10 13:52:13 +0000 <lambdabot> traverse_ h xs = foldr (\fx fxs -> h fx *> fxs) (pure ())
2023-12-10 13:52:13 +0000 <lambdabot> --OR
2023-12-10 13:52:13 +0000 <lambdabot> traverse_ h xs = traverse h xs *> pure ()
2023-12-10 13:52:24 +0000 <[Leary]> `traverse_` /is/ a fold.
2023-12-10 13:54:42 +0000machinedgod(~machinedg@93-136-52-133.adsl.net.t-com.hr) (Ping timeout: 252 seconds)
2023-12-10 13:55:54 +0000Aworks(~Aworks@2a09:bac2:c63:3cd::61:26e) (Ping timeout: 250 seconds)
2023-12-10 13:58:10 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 13:59:35 +0000acidjnk_new(~acidjnk@p200300d6e72b93299103c78233b0ca81.dip0.t-ipconnect.de) (Ping timeout: 268 seconds)
2023-12-10 14:00:28 +0000finn_elija(~finn_elij@user/finn-elija/x-0085643)
2023-12-10 14:00:28 +0000FinnElija(~finn_elij@user/finn-elija/x-0085643) (Killed (NickServ (Forcing logout FinnElija -> finn_elija)))
2023-12-10 14:00:28 +0000finn_elijaFinnElija
2023-12-10 14:02:40 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 14:11:50 +0000 <ski> Ashkan : yea, but do you want the last `s', in case you find a matching `b' ?
2023-12-10 14:13:12 +0000jtomas(~jtomas@90.162.208.36) (Quit: Leaving)
2023-12-10 14:14:10 +0000rosco(~rosco@175.136.152.56) (Quit: Lost terminal)
2023-12-10 14:14:34 +0000 <ski> @type traverse_ -- see `Foldable', not `Traversable'
2023-12-10 14:14:34 +0000 <lambdabot> (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
2023-12-10 14:15:42 +0000billchenchina(~billchenc@2a0d:2580:ff0c:1:e3c9:c52b:a429:5bfe) (Remote host closed the connection)
2023-12-10 14:16:14 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 14:16:25 +0000euleritian(~euleritia@dynamic-046-114-204-242.46.114.pool.telefonica.de) (Read error: Connection reset by peer)
2023-12-10 14:16:33 +0000billchenchina(~billchenc@2a0d:2580:ff0c:1:e3c9:c52b:a429:5bfe)
2023-12-10 14:16:42 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2023-12-10 14:16:42 +0000alexherbo2(~alexherbo@54.149.22.93.rev.sfr.net) (Ping timeout: 250 seconds)
2023-12-10 14:17:21 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
2023-12-10 14:18:11 +0000euleritian(~euleritia@77.22.252.56)
2023-12-10 14:18:59 +0000 <ski> @type mapAccumL
2023-12-10 14:18:59 +0000euleritian(~euleritia@77.22.252.56) (Read error: Connection reset by peer)
2023-12-10 14:19:00 +0000 <lambdabot> Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
2023-12-10 14:19:07 +0000 <ski> @type ((state . (swap .)) .) . flip . mapAccumL . flip . (((swap .) . runState) .) :: Traversable t => (a -> State s b) -> (t a -> State s (t b))
2023-12-10 14:19:08 +0000 <lambdabot> Traversable t => (a -> State s b) -> t a -> State s (t b)
2023-12-10 14:19:13 +0000 <ski> @type mapM :: Traversable t => (a -> State s b) -> (t a -> State s (t b))
2023-12-10 14:19:14 +0000 <lambdabot> Traversable t => (a -> State s b) -> t a -> State s (t b)
2023-12-10 14:19:40 +0000 <ski> @type traverse :: Traversable t => (a -> State s b) -> (t a -> State s (t b))
2023-12-10 14:19:41 +0000 <lambdabot> Traversable t => (a -> State s b) -> t a -> State s (t b)
2023-12-10 14:19:43 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2023-12-10 14:20:53 +0000 <ski> Ashkan : note that these do the same thing. doing a `foldl'-like operation (like `foldM' does), with an accumulator state `s', corresponds to doing a `traverse'/`mapM' on `StateT s'
2023-12-10 14:21:06 +0000 <Joao003> @type StateT
2023-12-10 14:21:07 +0000 <lambdabot> (s -> m (a, s)) -> StateT s m a
2023-12-10 14:21:21 +0000 <ski> @type runStateT
2023-12-10 14:21:22 +0000 <lambdabot> StateT s m a -> s -> m (a, s)
2023-12-10 14:21:42 +0000 <ski> @type state :: (s -> (a,s)) -> State s a
2023-12-10 14:21:43 +0000 <lambdabot> (s -> (a, s)) -> State s a
2023-12-10 14:21:48 +0000 <ski> @type runState
2023-12-10 14:21:49 +0000 <lambdabot> State s a -> s -> (a, s)
2023-12-10 14:22:04 +0000 <Joao003> @type State
2023-12-10 14:22:05 +0000 <lambdabot> error:
2023-12-10 14:22:05 +0000 <lambdabot> • Data constructor not in scope: State
2023-12-10 14:22:05 +0000 <lambdabot> • Perhaps you meant one of these:
2023-12-10 14:22:09 +0000 <Joao003> ...
2023-12-10 14:22:19 +0000nek0(~nek0@2a01:4f8:222:2b41::12) (Quit: The Lounge - https://thelounge.chat)
2023-12-10 14:22:20 +0000 <Joao003> @type State s a
2023-12-10 14:22:21 +0000 <lambdabot> error:
2023-12-10 14:22:21 +0000 <lambdabot> • Data constructor not in scope: State :: Expr -> Expr -> t
2023-12-10 14:22:21 +0000 <lambdabot> • Perhaps you meant one of these:
2023-12-10 14:22:26 +0000 <Joao003> wth
2023-12-10 14:22:29 +0000 <ski> Ashkan : in your case, you didn't want any new structure, with the elements replaced. so `traverse_'/`mapM_' instead
2023-12-10 14:22:43 +0000 <ski> @kind State
2023-12-10 14:22:44 +0000 <lambdabot> * -> * -> *
2023-12-10 14:23:07 +0000 <ski> @src State
2023-12-10 14:23:07 +0000 <lambdabot> type State s = StateT s Identity
2023-12-10 14:23:07 +0000 <lambdabot> --OR
2023-12-10 14:23:07 +0000 <lambdabot> data State s a = State { runState :: s -> (a, s) }
2023-12-10 14:23:19 +0000 <ski> the first one is what's in the library
2023-12-10 14:23:26 +0000 <ski> @src StateT
2023-12-10 14:23:26 +0000 <lambdabot> Source not found. Listen, broccoli brains, I don't have time to listen to this trash.
2023-12-10 14:23:29 +0000 <ski> ok
2023-12-10 14:23:50 +0000 <ski> newtype StateT s m a = StateT {runState :: s -> m (a,s)}
2023-12-10 14:23:56 +0000 <Joao003> @kind StateT
2023-12-10 14:23:57 +0000 <lambdabot> * -> (* -> *) -> * -> *
2023-12-10 14:28:33 +0000Joao003(~Joao003@190.108.99.32) (Quit: Bye!)
2023-12-10 14:29:01 +0000vgtw(~vgtw@user/vgtw) (Ping timeout: 246 seconds)
2023-12-10 14:29:29 +0000billchenchina(~billchenc@2a0d:2580:ff0c:1:e3c9:c52b:a429:5bfe) (Ping timeout: 268 seconds)
2023-12-10 14:33:43 +0000qqq(~qqq@92.43.167.61) (Ping timeout: 256 seconds)
2023-12-10 14:40:37 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 276 seconds)
2023-12-10 14:43:15 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 14:43:47 +0000vgtw(~vgtw@user/vgtw)
2023-12-10 14:47:28 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 14:50:40 +0000qqq(~qqq@92.43.167.61)
2023-12-10 14:51:20 +0000Square(~Square@user/square)
2023-12-10 14:53:32 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 14:54:00 +0000nek0(~nek0@2a01:4f8:222:2b41::12)
2023-12-10 14:57:15 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 15:11:26 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 15:16:21 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 15:17:04 +0000zetef(~quassel@82.76.107.234)
2023-12-10 15:17:17 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 268 seconds)
2023-12-10 15:19:04 +0000acidjnk_new(~acidjnk@p200300d6e72b93299103c78233b0ca81.dip0.t-ipconnect.de)
2023-12-10 15:23:15 +0000zetef(~quassel@82.76.107.234) (Remote host closed the connection)
2023-12-10 15:27:28 +0000Tlsx(rscastilho@189.61.140.215)
2023-12-10 15:28:27 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 15:35:13 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Ping timeout: 276 seconds)
2023-12-10 15:37:44 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 15:43:13 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 255 seconds)
2023-12-10 15:43:45 +0000Ashkan(~Ashkan@147.161.173.72) (Quit: Client closed)
2023-12-10 15:43:55 +0000euleritian(~euleritia@77.22.252.56)
2023-12-10 15:45:43 +0000azimut(~azimut@gateway/tor-sasl/azimut) (Ping timeout: 240 seconds)
2023-12-10 15:45:58 +0000son0p(~ff@181.136.122.143) (Remote host closed the connection)
2023-12-10 15:47:16 +0000vgtw(~vgtw@user/vgtw) (Ping timeout: 256 seconds)
2023-12-10 15:49:43 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 15:52:17 +0000wootehfoot(~wootehfoo@user/wootehfoot)
2023-12-10 15:54:33 +0000FinnElija(~finn_elij@user/finn-elija/x-0085643) (Killed (NickServ (Forcing logout FinnElija -> finn_elija)))
2023-12-10 15:54:34 +0000FinnElija(~finn_elij@user/finn-elija/x-0085643)
2023-12-10 15:55:04 +0000vgtw(~vgtw@user/vgtw)
2023-12-10 15:58:01 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 256 seconds)
2023-12-10 15:58:11 +0000target_i(~target_i@217.175.14.39)
2023-12-10 15:59:50 +0000son0p(~ff@181.136.122.143)
2023-12-10 16:00:39 +0000aruns(~aruns@user/aruns) (Ping timeout: 252 seconds)
2023-12-10 16:03:13 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 16:11:15 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 16:14:00 +0000smalltalkman(uid545680@id-545680.hampstead.irccloud.com)
2023-12-10 16:19:07 +0000azimut(~azimut@gateway/tor-sasl/azimut)
2023-12-10 16:22:54 +0000lg1882lg188
2023-12-10 16:26:31 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 16:28:44 +0000danza(~danza@151.43.234.184)
2023-12-10 16:30:20 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 252 seconds)
2023-12-10 16:30:54 +0000waleee(~waleee@h-176-10-144-38.NA.cust.bahnhof.se) (Ping timeout: 252 seconds)
2023-12-10 16:36:50 +0000danza(~danza@151.43.234.184) (Ping timeout: 268 seconds)
2023-12-10 16:39:18 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 16:45:08 +0000gdown(~gavin@h69-11-149-109.kndrid.broadband.dynamic.tds.net)
2023-12-10 16:48:20 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 16:48:31 +0000justsomeguy(~justsomeg@user/justsomeguy)
2023-12-10 16:50:05 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470) (Read error: Connection reset by peer)
2023-12-10 16:50:17 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 16:53:03 +0000DerDummNemetzkii(~John_Ivan@user/john-ivan/x-1515935)
2023-12-10 16:56:39 +0000[_](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 16:57:31 +0000vgtw(~vgtw@user/vgtw) (Ping timeout: 256 seconds)
2023-12-10 16:59:27 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 260 seconds)
2023-12-10 16:59:56 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470) (Ping timeout: 245 seconds)
2023-12-10 17:01:46 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 17:02:40 +0000tremon(~tremon@83.80.159.219)
2023-12-10 17:02:42 +0000mikess(~sam@user/mikess)
2023-12-10 17:09:49 +0000AlexZenon(~alzenon@178.34.162.199) (Ping timeout: 268 seconds)
2023-12-10 17:11:36 +0000Xe(~cadey@perl/impostor/xe) (Ping timeout: 245 seconds)
2023-12-10 17:13:41 +0000Xe(~cadey@perl/impostor/xe)
2023-12-10 17:13:42 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 17:13:53 +0000AlexZenon(~alzenon@178.34.162.199)
2023-12-10 17:17:43 +0000dhil(~dhil@2001:8e0:2014:3100:bf6:da90:7ddf:392e)
2023-12-10 17:22:20 +0000dcoutts(~duncan@cpc69402-oxfd27-2-0-cust903.4-3.cable.virginm.net)
2023-12-10 17:25:50 +0000laxmik(~laxmik@2a01:c23:9597:b700:707f:bbe3:5986:73cb)
2023-12-10 17:26:57 +0000arkoinad(~abhinav@c-67-169-139-16.hsd1.ca.comcast.net)
2023-12-10 17:27:50 +0000kimiamania464(~65804703@user/kimiamania)
2023-12-10 17:27:53 +0000laxmikmichals
2023-12-10 17:30:51 +0000kimiamania46(~65804703@user/kimiamania) (Ping timeout: 252 seconds)
2023-12-10 17:30:51 +0000kimiamania464kimiamania46
2023-12-10 17:40:02 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Ping timeout: 268 seconds)
2023-12-10 17:41:40 +0000michals(~laxmik@2a01:c23:9597:b700:707f:bbe3:5986:73cb) (Ping timeout: 250 seconds)
2023-12-10 17:41:55 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 17:44:31 +0000aruns(~aruns@user/aruns)
2023-12-10 17:48:15 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:d128:ce35:54e1:65e2) (Remote host closed the connection)
2023-12-10 17:48:30 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:d128:ce35:54e1:65e2)
2023-12-10 17:57:07 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 18:01:50 +0000 <haskellbridge> 12<C​elestial> How do I do cross-thread communication? Specifically I have a single parallel thread which basically dispenses ticks in a fixed time interval into a bounded channel. I want to control this tick delay time, but I'm not sure how to pass this information along to the other thread. I think there's something called an `MVar` which seems like it's kind of what I want? I'm not
2023-12-10 18:01:50 +0000 <haskellbridge> sure how to use this for…
2023-12-10 18:01:50 +0000 <haskellbridge> 12<C​elestial>  my specific use-case though
2023-12-10 18:02:59 +0000 <geekosaur> MVar or TVar, Chan or TChan, etc.
2023-12-10 18:03:15 +0000 <geekosaur> the T variants use STM
2023-12-10 18:03:44 +0000 <haskellbridge> 12<C​elestial> another thing I know nothing about haha
2023-12-10 18:03:53 +0000 <haskellbridge> 12<C​elestial> Is that this sort-of-escapable IO-ish thing?
2023-12-10 18:04:02 +0000 <geekosaur> no
2023-12-10 18:04:15 +0000 <geekosaur> it's software transactional memory
2023-12-10 18:04:47 +0000 <geekosaur> it won't let you commit a transaction unless every indivisual action can complete successfully; otherwise it retries
2023-12-10 18:04:57 +0000 <geekosaur> the ultimate result is an IO action
2023-12-10 18:05:11 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 18:05:31 +0000 <haskellbridge> 12<C​elestial> ah
2023-12-10 18:05:31 +0000 <geekosaur> https://www.microsoft.com/en-us/research/publication/composable-memory-transactions/
2023-12-10 18:05:54 +0000waleee(~waleee@h-176-10-144-38.NA.cust.bahnhof.se)
2023-12-10 18:05:58 +0000 <haskellbridge> 12<C​elestial> I think I was thinking of the ST monad?
2023-12-10 18:06:10 +0000 <geekosaur> yes
2023-12-10 18:06:15 +0000 <haskellbridge> 12<C​elestial> thank you
2023-12-10 18:06:15 +0000 <geekosaur> ST is unrelated to STM
2023-12-10 18:06:36 +0000tzh(~tzh@c-71-193-181-0.hsd1.or.comcast.net)
2023-12-10 18:07:35 +0000justsomeguy(~justsomeg@user/justsomeguy) (Read error: Connection reset by peer)
2023-12-10 18:08:41 +0000[_](~itchyjunk@user/itchyjunk/x-7353470) (Ping timeout: 245 seconds)
2023-12-10 18:08:48 +0000 <hexology> is there a way to define a general-purpose alias for an existing type? i wanted to create my own `Array2d i e` type as a shorthand for `Ix i => Array i (Array i e)`
2023-12-10 18:08:59 +0000 <hexology> that wouldn't work with newtype because it has more than one parameter, right?
2023-12-10 18:09:08 +0000 <geekosaur> `type`?
2023-12-10 18:09:40 +0000 <hexology> thank you!
2023-12-10 18:09:43 +0000 <hexology> https://en.wikibooks.org/wiki/Haskell/Type_declarations#type_for_making_type_synonyms
2023-12-10 18:09:58 +0000 <geekosaur> `newtype` is for when you want to either hide a type or override one or more typeclass instances
2023-12-10 18:10:29 +0000 <hexology> ah, i was wondering
2023-12-10 18:10:39 +0000pavonia(~user@user/siracusa) (Quit: Bye!)
2023-12-10 18:10:51 +0000 <hexology> and let's say i wanted to do that for something with more than one type parameter or constructor
2023-12-10 18:10:54 +0000 <hexology> how would i do that?
2023-12-10 18:11:01 +0000 <geekosaur> either way you're making a new distinct type from an existing one
2023-12-10 18:11:47 +0000 <hexology> oh, i can do that with `type` as well? so i can define my own typeclass instance for my `Array2d i e` and that would behave differently from `Array i (Array i e)`?
2023-12-10 18:12:16 +0000 <haskellbridge> 12<C​elestial> you can put (almost) anything that is a valid type as `type Foo = <type>` and then you can use it as if it was that exact type
2023-12-10 18:12:32 +0000 <haskellbridge> 12<C​elestial> you can't have instances with type
2023-12-10 18:12:43 +0000 <hexology> so what if i want to change how e.g. Foldable works on Array2d, what would i do then?
2023-12-10 18:12:46 +0000 <haskellbridge> 12<C​elestial> `type` creates a synonym / alias
2023-12-10 18:12:59 +0000 <geekosaur> all this said I'm not sure why you aren't using `type Array2d i e = Ix i => Array (i,i) e`
2023-12-10 18:13:04 +0000 <haskellbridge> 12<C​elestial> you'd need to wrap it in a `newtype`
2023-12-10 18:13:12 +0000 <geekosaur> Arays can be multidimensional
2023-12-10 18:13:25 +0000 <hexology> geekosaur: because i didn't realize i could do that!
2023-12-10 18:13:52 +0000 <hexology> i see, it's right here in the docs: (Ix a, Ix b) => Ix (a, b)
2023-12-10 18:13:57 +0000 <hexology> that's handy
2023-12-10 18:14:53 +0000 <haskellbridge> 12<C​elestial> you can even index by `Void`
2023-12-10 18:14:55 +0000 <hexology> but to answer the question above, if i want to customize the behavior of a `type` that differs from the underlying type, i'd need to create a newtype for it?
2023-12-10 18:14:57 +0000 <haskellbridge> 12<C​elestial> for that nice 0 dimensional array
2023-12-10 18:15:02 +0000 <geekosaur> yes
2023-12-10 18:15:18 +0000 <hexology> thanks a lot
2023-12-10 18:15:25 +0000 <geekosaur> `type` just creates aliases, changing behavior requires `newtype` or `data`
2023-12-10 18:15:46 +0000cimento(CO2@gateway/vpn/protonvpn/cimento) (Quit: WeeChat 4.1.2)
2023-12-10 18:15:49 +0000 <hexology> how does constructing an array with tuple indexes work?
2023-12-10 18:16:13 +0000cimento(CO2@gateway/vpn/protonvpn/cimento)
2023-12-10 18:16:47 +0000 <hexology> i've been using listArray, should i use something like `fill` instead?
2023-12-10 18:16:47 +0000 <geekosaur> the Ix instance lays them out in order (x0,y0),(x0,y1),…,(x1,y0),…
2023-12-10 18:17:17 +0000 <hexology> oh hang on i see. yeah i can pass the raw association data to `array` itself
2023-12-10 18:17:27 +0000 <hexology> ahh okay that helps too
2023-12-10 18:18:01 +0000 <hexology> so let's say i wanted a "column-major" array instead, i'd have to make a newtype for (i,j) and implement its Ix instance accordingly?
2023-12-10 18:18:20 +0000 <geekosaur> yes
2023-12-10 18:18:38 +0000 <hexology> where are you seeing that ordering for the Ix instance?
2023-12-10 18:19:10 +0000 <hexology> that is, how it corresponds to the underlying flat array order
2023-12-10 18:19:19 +0000 <hexology> still learning how to navigate these docs
2023-12-10 18:20:25 +0000 <hexology> or am i thinking about this the wrong way? where the underlying storage order is opaque/irrelevant
2023-12-10 18:20:42 +0000 <geekosaur> the top of https://downloads.haskell.org/ghc/9.2.5/docs/html/libraries/base-4.16.4.0/Data-Ix.html
2023-12-10 18:20:52 +0000 <geekosaur> "`Ix` uses row-major order:
2023-12-10 18:21:33 +0000 <hexology> right, but i guess i don't see how that's encoded in the definition or type signature
2023-12-10 18:22:02 +0000 <hexology> maybe that's in the implementation of `index`, `range`, etcD?
2023-12-10 18:22:13 +0000 <geekosaur> yes
2023-12-10 18:22:34 +0000wootehfoot(~wootehfoo@user/wootehfoot) (Quit: Leaving)
2023-12-10 18:22:52 +0000 <hexology> got it, i see now
2023-12-10 18:22:52 +0000 <hexology> thanks agin
2023-12-10 18:29:55 +0000DerDummNemetzkii(~John_Ivan@user/john-ivan/x-1515935) (Remote host closed the connection)
2023-12-10 18:30:16 +0000DerDummNemetzkii(~John_Ivan@user/john-ivan/x-1515935)
2023-12-10 18:31:10 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 18:32:52 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 18:33:11 +0000laxmik(~laxmik@2a01:c23:9597:b700:707f:bbe3:5986:73cb)
2023-12-10 18:33:47 +0000laxmik(~laxmik@2a01:c23:9597:b700:707f:bbe3:5986:73cb) (Client Quit)
2023-12-10 18:34:04 +0000duncan(~duncan@user/duncan)
2023-12-10 18:34:43 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) (Quit: Reconnecting)
2023-12-10 18:34:56 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 18:36:04 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net) ()
2023-12-10 18:36:18 +0000tri(~tri@ool-18bc2e74.dyn.optonline.net)
2023-12-10 18:36:18 +0000 <haskellbridge> 12<C​elestial> I'm now stuck with a "thread blocked indefinitely in an MVar operation" lol
2023-12-10 18:40:05 +0000 <hexology> `foreach = flip map` this is saving my life right now... making really easy to translate the imperative algorithms in my head for a first draft, then i can refactor once it's all written out
2023-12-10 18:40:10 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 18:42:10 +0000 <Hecate> 👍
2023-12-10 18:43:13 +0000 <yushyin> :t for
2023-12-10 18:43:14 +0000 <lambdabot> (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
2023-12-10 18:43:17 +0000 <yushyin> :t forM
2023-12-10 18:43:18 +0000 <lambdabot> (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
2023-12-10 18:44:04 +0000 <hexology> is there an Identity applicative?
2023-12-10 18:44:28 +0000 <Rembane> The Identity monad should have an applicative instance.
2023-12-10 18:44:37 +0000 <hexology> thanks
2023-12-10 18:44:51 +0000 <hexology> is there any particular reason that's better than `flip map`?
2023-12-10 18:44:58 +0000 <hexology> (but good to know about for sure)
2023-12-10 18:46:00 +0000 <Rembane> You get all the fun from Functor, Applicative and Monad. :D
2023-12-10 18:47:17 +0000 <haskellbridge> 12<C​elestial> not really useful in this case, but you'll also get used to the order that `map` is the mapping function first :P
2023-12-10 18:47:48 +0000 <haskellbridge> 12<C​elestial> it also makes sense in the higher order context because you can write somehing like `double = map (*2)`
2023-12-10 18:48:08 +0000 <haskellbridge> 12<C​elestial> you can also use `<$>` infix if you like!
2023-12-10 18:48:13 +0000 <hexology> yeah to be clear, i'm used to it and i understand why it's like that. but when i'm writing out a nest of 3 map's with lambdas, putting the thing i'm iterating over before the (\ x ->) makes it easier to read
2023-12-10 18:48:23 +0000duncan(~duncan@user/duncan)
2023-12-10 18:48:28 +0000 <haskellbridge> 12<C​elestial> `length <$> ["Hello", "World"]`
2023-12-10 18:48:53 +0000 <hexology> hah true. but again that has the same issue, it doesn't look and feel like the for loop that's in my head
2023-12-10 18:49:05 +0000 <haskellbridge> 12<C​elestial> this sounds like you want to write some "smaller" functions and compose them upstream ;)
2023-12-10 18:49:26 +0000 <hexology> indeed. but i tend to think "top-down" so i don't know what those smaller functions will look like until the algorithm is all written out
2023-12-10 18:50:05 +0000 <hexology> i believe the ancient masters used tools called "pen & paper" for this, but i'm unfamiliar with such mysterious arts
2023-12-10 18:50:52 +0000 <hexology> (my penmanship has degraded badly over the years and i need to get back in the habit of writing stuff down)
2023-12-10 18:51:15 +0000 <hexology> actually maybe this is good motivation. use a notepad instead of `flip map`
2023-12-10 18:51:38 +0000 <haskellbridge> 12<C​elestial> I do that too, but I usually just build functions up as I need them - basically I write `f = foo . bar . baz` and then let HLS generate each of the signatures
2023-12-10 18:51:52 +0000 <haskellbridge> 12<C​elestial> then I implement those with "unknown" functions as needed and implement those
2023-12-10 18:51:56 +0000 <hexology> HLS can generate signatures? is that a code action?
2023-12-10 18:52:48 +0000 <haskellbridge> 12<C​elestial> https://matrix-client.matrix.org//26caf53b/image.png
2023-12-10 18:52:57 +0000 <haskellbridge> 12<C​elestial> oh wait you can't see that on the irc side
2023-12-10 18:52:58 +0000 <haskellbridge> 12<C​elestial> yes
2023-12-10 18:53:11 +0000 <hexology> i can hop on matrix too
2023-12-10 18:53:26 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 18:53:31 +0000 <haskellbridge> 12<C​elestial> or rather it defines the function with a hole implementation and a signature
2023-12-10 18:53:43 +0000 <haskellbridge> 12<C​elestial> hexology: not worth it for that image :)
2023-12-10 18:53:58 +0000 <hexology> it's maybe easier anyway for code formatting etc. plus i can tag you there
2023-12-10 18:54:23 +0000 <hexology> what room is this bridged to? https://matrix.to/#/#haskell:matrix.org looks like a completely different conversation happening
2023-12-10 18:54:36 +0000 <hexology> oh i see there's a space
2023-12-10 18:54:40 +0000duncan(~duncan@user/duncan)
2023-12-10 18:54:40 +0000 <hexology> and an irc-bridged room
2023-12-10 18:54:46 +0000 <hexology> kind of you to idle in here for us lost souls on irc
2023-12-10 18:57:22 +0000euleritian(~euleritia@77.22.252.56) (Ping timeout: 276 seconds)
2023-12-10 18:57:34 +0000euleritian(~euleritia@dynamic-046-114-200-254.46.114.pool.telefonica.de)
2023-12-10 18:57:53 +0000 <hexology> maybe they can add a link to the main haskell-space room in the topic here? it's not that easy to find unless you know what you're doing with matrix
2023-12-10 18:58:54 +0000vgtw(~vgtw@user/vgtw)
2023-12-10 18:59:13 +0000 <haskellbridge> 12<C​elestial> I think this room specifically is targetted towards IRC
2023-12-10 19:00:13 +0000euleritian(~euleritia@dynamic-046-114-200-254.46.114.pool.telefonica.de) (Read error: Connection reset by peer)
2023-12-10 19:00:31 +0000euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2023-12-10 19:01:56 +0000 <Rembane> hexology: There's a list of community resources here, e.g. this channel and Matrix: https://www.haskell.org/community/
2023-12-10 19:02:22 +0000 <Rembane> So that's something.
2023-12-10 19:05:18 +0000 <geekosaur> IRC came first by several decades by the way, and there's a bunch of folks in here who don't use Matrix
2023-12-10 19:05:52 +0000dhil(~dhil@2001:8e0:2014:3100:bf6:da90:7ddf:392e) (Ping timeout: 246 seconds)
2023-12-10 19:12:58 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 19:13:42 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 19:14:27 +0000 <hexology> geekosaur: indeed, but in this case it would have been useful to know which matrix room this was bridged to
2023-12-10 19:14:34 +0000 <hexology> Rembane: those are helpful
2023-12-10 19:14:49 +0000 <Rembane> hexology: Sweet! :)
2023-12-10 19:15:31 +0000 <geekosaur> if you /whois the bridge bot, it includes a link showing all the bridged channels and their matrix rooms
2023-12-10 19:15:50 +0000 <geekosaur> there's a limit to how big topics can get
2023-12-10 19:16:25 +0000 <hexology> that's the "matterbridge" link?
2023-12-10 19:16:32 +0000duncan(~duncan@user/duncan)
2023-12-10 19:16:41 +0000 <hexology> looks like it. thanks
2023-12-10 19:17:16 +0000testing500(~user@host-92-11-94-158.as13285.net)
2023-12-10 19:17:41 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 240 seconds)
2023-12-10 19:17:55 +0000duncan(~duncan@user/duncan) (Client Quit)
2023-12-10 19:19:53 +0000 <tomsmeding> lol, that goes to a paste
2023-12-10 19:19:57 +0000 <tomsmeding> I guess that works :)
2023-12-10 19:20:23 +0000 <tomsmeding> geekosaur: feel free to link to https://paste.tomsmeding.com/syOTuo6O/raw if you want
2023-12-10 19:20:48 +0000 <hexology> it looks like that's in there, but with a shortened url
2023-12-10 19:21:12 +0000 <tomsmeding> yes I was just surprised that it just went to a paste instead of a dedicated page :)
2023-12-10 19:21:20 +0000 <tomsmeding> fist the hacker spirit though
2023-12-10 19:26:15 +0000 <EvanR> still not exactly sure what [the] matrix is
2023-12-10 19:26:25 +0000 <EvanR> should I follow the white rabbit?
2023-12-10 19:27:13 +0000duncan(~duncan@user/duncan)
2023-12-10 19:27:21 +0000duncan(~duncan@user/duncan) (Remote host closed the connection)
2023-12-10 19:27:31 +0000 <EvanR> 💊
2023-12-10 19:32:25 +0000testing500(~user@host-92-11-94-158.as13285.net) (Remote host closed the connection)
2023-12-10 19:43:05 +0000pagnol(~user@2a02:a210:a3c:b00:87aa:b531:d3b2:73fa)
2023-12-10 19:46:08 +0000jargon(~jargon@32.sub-174-238-226.myvzw.com)
2023-12-10 19:48:33 +0000 <monochrom> Someone should create a competitor to Matrix and call it Wave. >:)
2023-12-10 19:50:14 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com)
2023-12-10 19:58:31 +0000trev(~trev@user/trev) (Quit: trev)
2023-12-10 20:10:04 +0000Tlsx(rscastilho@189.61.140.215) (Remote host closed the connection)
2023-12-10 20:10:10 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com) (Ping timeout: 276 seconds)
2023-12-10 20:11:29 +0000glider(~glider@user/glider) (Quit: ZNC - https://znc.in)
2023-12-10 20:17:21 +0000 <cheater> let's say i have data Foo a b = Error | Bar a b | Quux a b. How can I write a case so that both a and b get captured whether it's Bar or Quux?
2023-12-10 20:18:10 +0000 <cheater> i'm thinking of something like case myFoo of { Error -> ...; Bar x y, Quux x y -> runFunc x y }
2023-12-10 20:19:53 +0000 <dminuoso_> cheater: Write them as separate branches.
2023-12-10 20:20:28 +0000 <cheater> don't really want separate branches (instead of runFunc x y i have a pretty large block)
2023-12-10 20:20:29 +0000 <tromp> Haskell doesn't support that. although there is this proposal https://wiki.haskell.org/MultiCase
2023-12-10 20:20:32 +0000 <dminuoso_> There's some ongoing GHC proposals to accomplish part of this, but I dont follow them because they lack the one thing to make them useful.
2023-12-10 20:20:41 +0000 <cheater> i guess i could extract that block and put it in a function, or something.
2023-12-10 20:20:56 +0000 <cheater> "the one thing"?
2023-12-10 20:22:37 +0000 <dminuoso_> https://github.com/ghc-proposals/ghc-proposals/pull/585
2023-12-10 20:22:43 +0000 <dminuoso_> https://github.com/ghc-proposals/ghc-proposals/pull/609
2023-12-10 20:24:14 +0000 <cheater> what is "the one thing"?
2023-12-10 20:24:22 +0000 <dminuoso_> Oh. Binding variables.
2023-12-10 20:24:55 +0000td_(~td@i53870907.versanet.de) (Ping timeout: 256 seconds)
2023-12-10 20:24:59 +0000 <hexology> if i write `let inputLines = lines inputText in n = length inputLines` is GHC "smart enough" to compile that to a single loop over the data, or would i have to reimplement `lines` myself to get that kind of performance?
2023-12-10 20:26:01 +0000 <hexology> or similarly if i write `zip [0..] (lines inputText)`
2023-12-10 20:26:59 +0000 <Rembane> hexology: IIRC It should be evaluated only once.
2023-12-10 20:27:04 +0000 <dminuoso_> cheater: It roughly degrades the proposal to case-of on numbers, literals or nullary constructors.
2023-12-10 20:27:19 +0000 <dminuoso_> For anything else, you (probably) still have to write out each branch by hand.
2023-12-10 20:27:22 +0000 <cheater> ugh
2023-12-10 20:27:38 +0000alp_(~alp@2001:861:e3d6:8f80:7092:9744:337:b98c)
2023-12-10 20:27:50 +0000 <hexology> Rembane: thanks. do you know of any resources for understanding performance in cases like this? not sure what the tooling landscape looks like for things like profiling
2023-12-10 20:28:14 +0000 <EvanR> monochrom, took me a minute but I got the reference
2023-12-10 20:29:59 +0000 <Rembane> hexology: The trick is generally to see if the thunks get evaluated. I would just ignore them until they bite you.
2023-12-10 20:30:19 +0000Unicorn_Princess(~Unicorn_P@user/Unicorn-Princess/x-3540542)
2023-12-10 20:30:30 +0000 <hexology> this is more of out interest/curiosity than any particular need
2023-12-10 20:34:00 +0000 <EvanR> let inputLines = lines inputText; n = length inputLines in ...
2023-12-10 20:34:06 +0000 <EvanR> perhaps
2023-12-10 20:34:27 +0000anderson(~anderson@user/anderson)
2023-12-10 20:35:15 +0000 <hexology> i'm not sure about all the semicolon rules yet, so i used 2 `let`s instead
2023-12-10 20:35:17 +0000 <EvanR> if ... only uses n, then you only loop over inputText at most once
2023-12-10 20:35:26 +0000 <EvanR> your only had 1 let
2023-12-10 20:35:32 +0000 <hexology> oh
2023-12-10 20:35:37 +0000 <hexology> i meant to have 2
2023-12-10 20:35:37 +0000 <APic> lol
2023-12-10 20:35:47 +0000 <hexology> s/in n/in let in/
2023-12-10 20:35:50 +0000 <hexology> letn
2023-12-10 20:35:55 +0000 <EvanR> ok makes more sense now
2023-12-10 20:35:56 +0000 <hexology> i give up, you know what i mean :)
2023-12-10 20:36:57 +0000 <hexology> maybe this is another XY problem. i'm doing AoC day 3 (trying to catch up) and i wanted to read the input into a 2D array of Chars
2023-12-10 20:36:58 +0000 <EvanR> but if inputText appears in several places in ..., you might not only loop over it multiple times but it will be fully materialized in heap memory
2023-12-10 20:37:17 +0000__monty__(~toonn@user/toonn)
2023-12-10 20:37:55 +0000 <hexology> right, that's what i wasn't sure of
2023-12-10 20:39:09 +0000 <EvanR> so if you wanted to accomplish multiple things during a traversal of inputText, I think you would do it with 1 fold or write your own recursion
2023-12-10 20:39:41 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com)
2023-12-10 20:39:58 +0000 <EvanR> or do like me, and reload the file each time xD
2023-12-10 20:40:12 +0000 <hexology> got it. in this case i was hoping to go from `inputText :: String` to `inputData :: Array (Int, Int) Char`, but maybe it's impossible to do that in a single pass without an intermediate list of lines, because you need the length of each line and the number of lines
2023-12-10 20:40:31 +0000 <hexology> so i was hoping to at least get the number of lines and the intermediate list of lines in a single shot
2023-12-10 20:41:11 +0000 <hexology> of course none of this matters for aoc day3 specifically, but again i'm taking this as a learning and exploration opportunity
2023-12-10 20:41:34 +0000 <EvanR> you can't get the number of lines until after all the lines have been identified
2023-12-10 20:41:49 +0000 <EvanR> it basically last
2023-12-10 20:42:35 +0000 <EvanR> if you want to use Array dunno if there's a way around it
2023-12-10 20:42:52 +0000 <hexology> right, that much i know. but you can also get the lines and the number thereof in a single pass, if you reimplement `lines` yourself
2023-12-10 20:43:01 +0000 <hexology> at least i'm pretty sure that should be possible
2023-12-10 20:43:12 +0000 <probie> What does "a single pass" mean?
2023-12-10 20:43:17 +0000 <EvanR> when you get lines you can start using the lines before you're finished reading the input
2023-12-10 20:43:28 +0000 <EvanR> unlike the integer number of total lines, which must wait until the end
2023-12-10 20:44:00 +0000 <EvanR> implementing lines yourself won't help there
2023-12-10 20:44:18 +0000 <hexology> probie: i mean `for (line in lines) { ... }` -- not doing that more times than necessary
2023-12-10 20:44:36 +0000 <probie> Is `map ((*2) . (+1))` a single pass, or two passes?
2023-12-10 20:44:44 +0000 <dminuoso_> Yes.
2023-12-10 20:44:53 +0000 <hexology> probie: that's up to GHC but i would hope that it's one
2023-12-10 20:45:08 +0000 <c_wraith> I don't know how you could implement map that would make it two passes
2023-12-10 20:45:22 +0000 <probie> If I go `head . map ((*2) . (+1))` how many times have I passed over the list?
2023-12-10 20:45:33 +0000 <dminuoso_> c_wraith: Still, it depends a bit on how you interpret "pass"
2023-12-10 20:45:34 +0000 <c_wraith> the important question is whether `map (*2) . map (+1)` is one pass or two
2023-12-10 20:45:44 +0000 <hexology> c_wraith: precisely, that's the essence of what i'm asking here
2023-12-10 20:45:45 +0000 <dminuoso_> So my answer remains: yes.
2023-12-10 20:45:46 +0000 <EvanR> or zero
2023-12-10 20:45:56 +0000 <EvanR> any haskell code could be doing zero passes
2023-12-10 20:46:00 +0000 <EvanR> depending
2023-12-10 20:46:25 +0000 <c_wraith> probie: by my counting zero passes when you have head. It only ever evaluates the first (:) constructor and its first argument
2023-12-10 20:47:05 +0000 <hexology> EvanR: i was envisioning exactly two passes here: 1) to split the string into lines and accumulate a length counter, then 2) to pull all the strings into the array
2023-12-10 20:47:34 +0000 <hexology> was i was wondering (again, mostly academic) is whether calling `length` on `lines inputText` is equivalent to (1), or if that ends up being compiled to a 3rd loop
2023-12-10 20:48:08 +0000 <hexology> or if internally GHC internally tracks the sizes of known-finite lists and it doesn't matter
2023-12-10 20:48:12 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 20:48:15 +0000 <hexology> (tracks at runtime*)
2023-12-10 20:48:26 +0000 <dminuoso_> probie: A more interesting question is whether `map (*2) . map (+1)` will map twice or not.
2023-12-10 20:48:31 +0000 <EvanR> it'll probably loop over the list of lines to get the length
2023-12-10 20:49:15 +0000 <dminuoso_> Which in principle would map twice, but GHC has a bunch of RULES that will - if they fire - do short cut fusion here.
2023-12-10 20:49:45 +0000 <EvanR> and writing a function to return a length and the list of lines in a tuple by itself won't help you with making the array, because the array builder will evaluate the length first
2023-12-10 20:49:46 +0000 <dminuoso_> probie: As a point of interest: for guaranteed short cut fusion in the general fmap case (i.e. repeated fmap applications) use Yoneda.
2023-12-10 20:49:53 +0000 <dminuoso_> Or even in the list case.
2023-12-10 20:50:01 +0000 <dminuoso_> If you rely on this happening, use Yoneda.
2023-12-10 20:50:09 +0000 <hexology> EvanR: right. to be clear, i was talking about getting the list of lines and the length in one pass, not building the array
2023-12-10 20:50:39 +0000 <hexology> (unless haskell has resizeable arrays where you can pre-allocate a bunch of lines, like what cpython does internally for lists)
2023-12-10 20:50:41 +0000 <EvanR> hexology, yes but... getting a list of lines is lazy and an Int isn't
2023-12-10 20:51:09 +0000 <EvanR> when you make a Vector from a list, it does resize as it discovers the list is bigger and bigger, iirc
2023-12-10 20:51:30 +0000 <EvanR> in which case you don't need the length ahead of time. But there is another builder function which allows you to inform the known length if you have it
2023-12-10 20:51:43 +0000 <hexology> i haven't tried using Vector yet, only Array
2023-12-10 20:52:00 +0000 <hexology> good to know something like that exists
2023-12-10 20:52:12 +0000 <hexology> but i think your point about lines of being lazy is clarifying
2023-12-10 20:53:26 +0000 <hexology> `lines inputText` doesn't immediately create a list, it builds up some kind of graph of thunks, right?
2023-12-10 20:53:54 +0000 <EvanR> at best it doesn't do anything, if you don't use it for anything. Second best is it creates one thunk ready to start producing lines
2023-12-10 20:54:26 +0000 <EvanR> near the worst cases, yes there will be a bunch of thunks for some reason
2023-12-10 20:54:32 +0000 <EvanR> that's usually a mistake
2023-12-10 20:54:50 +0000 <probie> > take 0 $ lines (error "Oh no")
2023-12-10 20:54:51 +0000 <lambdabot> []
2023-12-10 20:57:28 +0000 <hexology> got it
2023-12-10 20:58:27 +0000pretty_dumm_guy(trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655) (Quit: WeeChat 3.5)
2023-12-10 20:58:56 +0000 <EvanR> and since you're using String = [Char], each line is itself lazy (ideally)
2023-12-10 20:59:00 +0000pretty_dumm_guy(trottel@gateway/vpn/protonvpn/prettydummguy/x-88029655)
2023-12-10 20:59:23 +0000 <hexology> it's from `inputText <- getContents` in this case
2023-12-10 21:00:11 +0000 <hexology> so i would hope that it's doing something like buffering stdin, iterating over bytes until `\n` is encountered, adding those bytes to the list it's building up, and incrementing the length counter i requested with `length`
2023-12-10 21:00:39 +0000 <EvanR> that sounds like some other language xD
2023-12-10 21:01:05 +0000 <EvanR> when you based the computation on getContents, it only reads a Char from stdin if it's needed
2023-12-10 21:01:24 +0000 <EvanR> so if you process the lines char by char, and line by line, in order, then it only needs 1 Char lookahead
2023-12-10 21:01:54 +0000alexherbo2(~alexherbo@2a02-8440-3140-cd78-808d-cfaa-bb42-954e.rev.sfr.net)
2023-12-10 21:03:10 +0000 <EvanR> but using the length of a line or total number of lines will potentially mess that up
2023-12-10 21:03:17 +0000 <hexology> https://bpa.st/EPDA this is basically what i'm doing
2023-12-10 21:03:39 +0000 <hexology> err, not show, print
2023-12-10 21:03:54 +0000 <hexology> but that's the general idea
2023-12-10 21:04:04 +0000 <EvanR> right
2023-12-10 21:04:05 +0000 <monochrom> With "inputText <- getContents" if you add "let foo = lines inputText" then foo is the list of lines.
2023-12-10 21:05:18 +0000 <EvanR> if somethingUseful accesses the array at all, then all the lines will be processed first to get the lengths
2023-12-10 21:06:36 +0000 <EvanR> so that's where your "buffering" would come from, it's not a given
2023-12-10 21:07:04 +0000 <hexology> makes sense
2023-12-10 21:07:14 +0000 <hexology> wait, GHC doesn't do any of its own i/o buffering?
2023-12-10 21:07:22 +0000 <hexology> i know usually the OS does, but still
2023-12-10 21:07:32 +0000 <EvanR> yeah but that has no bearing here
2023-12-10 21:07:51 +0000 <hexology> sure. just following the thread, so to speak
2023-12-10 21:07:56 +0000alexherbo2(~alexherbo@2a02-8440-3140-cd78-808d-cfaa-bb42-954e.rev.sfr.net) (Ping timeout: 250 seconds)
2023-12-10 21:07:58 +0000 <EvanR> whether there's buffering in the backend you can still work with 1 char at a time
2023-12-10 21:08:02 +0000 <hexology> right
2023-12-10 21:08:28 +0000 <EvanR> whether you build up a bunch of chars in the process depends on how you do it
2023-12-10 21:08:36 +0000 <hexology> presumably in a real application with nontrivial performance requirements, i'd be able to use the GHC profiling tools to understand what's going on?
2023-12-10 21:08:40 +0000 <hexology> https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#
2023-12-10 21:08:49 +0000 <monochrom> Here is the simplest way to see the phenomenon. "sum [1..n]" takes O(1) space. "length [1..n]" also takes O(1) space. But "let xs = [1..n] in sum xs / length xs" takes linear space. You have to understand lazy evaluation to see why.
2023-12-10 21:09:06 +0000duncan(~duncan@user/duncan)
2023-12-10 21:09:16 +0000duncan(~duncan@user/duncan) (Client Quit)
2023-12-10 21:09:19 +0000 <probie> hexology: In a real application with nontrivial performance requirements, you would neither be using `getContents` nor the `String` type :p
2023-12-10 21:09:29 +0000 <EvanR> profiling is an easy way to identify big use of heap space when you didn't think you needed it
2023-12-10 21:09:45 +0000 <hexology> what would you use for text data intead? https://hackage.haskell.org/package/text-1.2.4.1/docs/Data-Text.html this?
2023-12-10 21:09:47 +0000 <EvanR> and yeah list of Char is bad for performance
2023-12-10 21:10:16 +0000 <monochrom> And I refuse the current ambiguous wording "buffering". You are conflating I/O buffers with keeping the whole string in memory.
2023-12-10 21:10:22 +0000 <EvanR> advent of code only uses ASCII text input so ByteString would also work
2023-12-10 21:11:27 +0000 <hexology> monochrom: you're right, i should have been clearer. when i said "buffer" i meant an I/O buffer
2023-12-10 21:12:17 +0000 <hexology> and that example above does help clarify
2023-12-10 21:12:21 +0000 <EvanR> if you use ByteString then you will be working with an array of bytes, mapping more closely to what you were "hoping" for
2023-12-10 21:12:27 +0000 <monochrom> Of course GHC does I/O buffers by default. But all languages do O(1)-space I/O buffers. 4KB or 64KB or something.
2023-12-10 21:13:15 +0000 <EvanR> list nodes and Char itself take up quite a bit more space and time than array of bytes
2023-12-10 21:13:50 +0000 <EvanR> because lisp machines didn't win!
2023-12-10 21:14:17 +0000 <hexology> i got interested in languages' I/O buffering when i wrote a cli tool that looped over lines of input in python, and it smoked every other non-compiled language in performance when i benchmarked an idiomatic but non-optimized implementation, including luajit, sbcl, chez scheme, and nodejs. i was pretty surprised at this, and the best i could gather after some digging around is that cpython uses a much bigger stdin buffer than the others
2023-12-10 21:14:25 +0000 <monochrom> But even in C I wouldn't use this algorithm "read the whole file in memory" unless the file is known to be small.
2023-12-10 21:15:02 +0000_ht(~Thunderbi@28-52-174-82.ftth.glasoperator.nl) (Remote host closed the connection)
2023-12-10 21:15:07 +0000 <hexology> also a good point monochrom
2023-12-10 21:15:10 +0000 <EvanR> where "small" has been steadily increasing in size over time xD
2023-12-10 21:15:27 +0000 <monochrom> If I need to create an array whose size depends on the number of lines, I would create a growable array instead.
2023-12-10 21:15:29 +0000 <EvanR> it's only a 1 meg file? load it all into memory for some reason xD
2023-12-10 21:15:30 +0000 <dminuoso_> I was always under the assumption that "buffering" isnt as much ambiguous, as it is just plainly misused.
2023-12-10 21:15:57 +0000 <dminuoso_> Buffers are a tool for matching two I/O that may, potentially, operate at different speeds.
2023-12-10 21:16:13 +0000 <monochrom> Either that, or pre-scan the file (but don't store) for number of lines, then rewind and read for real.
2023-12-10 21:16:15 +0000 <dminuoso_> It's not a means for "streaming", its rather a solution to avoid data loss.
2023-12-10 21:19:29 +0000 <monochrom> Unpopular opinion but I first ask the question "is your algorithm even O(1)-space in theory?" instead of the popular knee-jerk "Text takes 1/4 of the space taken up by [Char]".
2023-12-10 21:19:35 +0000duncan(~duncan@user/duncan)
2023-12-10 21:19:56 +0000foul_owl(~kerry@174-21-66-189.tukw.qwest.net) (Ping timeout: 245 seconds)
2023-12-10 21:20:29 +0000 <hexology> monochrom: i would hope that's not unpopular!
2023-12-10 21:20:36 +0000 <monochrom> The assumption of the latter is that at the professional level you already have a O(1)-space algorithm but its constant multiplier is terrible so now you look for 4x efficiency boosts.
2023-12-10 21:20:50 +0000 <EvanR> yeah the main point of this discussion would apply to String, Text, and ByteString
2023-12-10 21:21:09 +0000 <EvanR> laziness in the face of needing the know the lengths
2023-12-10 21:21:15 +0000 <monochrom> But the assumption is blatantly broken. 99.9% of askers are absolute beginners, their algorithms begin with expoenential time already, a 4x boost doesn't solve anything.
2023-12-10 21:21:24 +0000 <monochrom> And in fact becomes completely distracting.
2023-12-10 21:25:47 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 21:26:57 +0000duncan(~duncan@user/duncan)
2023-12-10 21:27:41 +0000 <hc> Exponential time? Not just quadratic?
2023-12-10 21:28:18 +0000 <hc> I'd expect many naive string handling algorithms to be polynomial, but not exponential
2023-12-10 21:29:48 +0000target_i(~target_i@217.175.14.39) (Quit: leaving)
2023-12-10 21:31:36 +0000emmanuelux_(~emmanuelu@user/emmanuelux) (Read error: Connection reset by peer)
2023-12-10 21:32:31 +0000 <dminuoso_> monochrom: On the basis that the observable universe is finite in size and energy, there exists a finite amount of memory I could theoretically ever use. So all practial algorithms are O(1)-space with.. well.. a huge constant factor.
2023-12-10 21:32:40 +0000emmanuelux_(~emmanuelu@user/emmanuelux)
2023-12-10 21:33:14 +0000foul_owl(~kerry@157.97.134.168)
2023-12-10 21:34:14 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl)
2023-12-10 21:34:28 +0000emmanuelux_(~emmanuelu@user/emmanuelux) (Max SendQ exceeded)
2023-12-10 21:35:30 +0000emmanuelux_(~emmanuelu@user/emmanuelux)
2023-12-10 21:36:02 +0000not_reserved(~not_reser@45.88.222.248)
2023-12-10 21:38:05 +0000 <newsham> you could claim that all your programs run on a finite state machine, but it wouldnt be very useful or insightful.
2023-12-10 21:40:12 +0000 <haskellbridge> 12<C​elestial> Is there an `MVar`-ish type that always has a value, or should I just write my own newtype wrapper around `MVar` that doesn't neither has the empty smart constructor nor the take operation but only a swap?
2023-12-10 21:40:13 +0000 <haskellbridge> 12<C​elestial> Is that "safe", as swap still needs to take and put again, leaving a short window where it's empty?
2023-12-10 21:40:31 +0000 <haskellbridge> 12<C​elestial> I suppose the later isn't a concern if you only allow the blocking operations that wait
2023-12-10 21:40:56 +0000 <haskellbridge> 12<C​elestial> s/doesn't neither/neither
2023-12-10 21:41:04 +0000 <monochrom> I would consider STM and its TVar instead.
2023-12-10 21:41:43 +0000 <monochrom> But if you stick to readMVar and writeMVar you get the always-non-empty semantics.
2023-12-10 21:42:50 +0000 <haskellbridge> 12<C​elestial> hm I see I think I do want the TVar instead
2023-12-10 21:42:59 +0000 <haskellbridge> 12<C​elestial> I need to read up on the STM monad
2023-12-10 21:43:02 +0000 <EvanR> IORef xD
2023-12-10 21:43:10 +0000 <EvanR> atomicModifyIORef'
2023-12-10 21:43:35 +0000 <monochrom> Yeah I actually use that :)
2023-12-10 21:43:49 +0000 <EvanR> TVars are good when you actually want transactions
2023-12-10 21:43:58 +0000 <EvanR> more complicated than just changing the value
2023-12-10 21:44:11 +0000 <haskellbridge> 12<C​elestial> how does one interact with STM? For IO you have the entry point `main` but there doesn't seem to be the same with stm?
2023-12-10 21:44:18 +0000 <EvanR> atomically
2023-12-10 21:44:37 +0000 <monochrom> If it is not "two or more variables entangled by an invariant" then atomicModifyIORef' suffices.
2023-12-10 21:44:43 +0000alexherbo2(~alexherbo@2a02-8440-3140-cd78-e0d9-a0e2-1a64-1fd2.rev.sfr.net)
2023-12-10 21:45:25 +0000fendor(~fendor@2a02:8388:1605:d100:267b:1353:13d7:4f0c) (Remote host closed the connection)
2023-12-10 21:46:52 +0000pavonia(~user@user/siracusa)
2023-12-10 21:47:34 +0000aruns(~aruns@user/aruns) (Ping timeout: 246 seconds)
2023-12-10 21:48:12 +0000duncan(~duncan@user/duncan) (Read error: Connection reset by peer)
2023-12-10 21:49:00 +0000duncan(~duncan@user/duncan)
2023-12-10 21:52:11 +0000anderson(~anderson@user/anderson) (Quit: bye)
2023-12-10 21:53:59 +0000anderson(~anderson@user/anderson)
2023-12-10 21:54:11 +0000duncan(~duncan@user/duncan) (Quit: ZNC 1.8.2 - https://znc.in)
2023-12-10 21:57:51 +0000takuan(~takuan@178-116-218-225.access.telenet.be) (Ping timeout: 256 seconds)
2023-12-10 21:59:42 +0000 <EvanR> *do you guys just put "quantum" in front of everything*
2023-12-10 21:59:48 +0000machinedgod(~machinedg@93-136-52-133.adsl.net.t-com.hr)
2023-12-10 22:00:19 +0000duncan(~duncan@user/duncan)
2023-12-10 22:04:35 +0000 <ski> Celestial : `Array () e' would be a zero-dimensional array (having a single element of type `e'). if `Array (Either i j) e' was allowed, it would amount to two arrays, side-by side. `Array Void e' corresponds to zero arrays (so no elements of type `e')
2023-12-10 22:04:39 +0000 <ski> hexology : sometimes i define `pam = flip map'
2023-12-10 22:04:43 +0000 <ski> cheater : "i'm thinking of something like case myFoo of { Error -> ...; Bar x y, Quux x y -> runFunc x y }" -- you're asking for disjunctive / "or"- patterns
2023-12-10 22:05:22 +0000 <jackdk> > :t Data.Functor.(<&>)
2023-12-10 22:05:23 +0000 <lambdabot> <hint>:1:1: error: parse error on input ‘:’
2023-12-10 22:05:32 +0000 <jackdk> % :t Data.Functor.(<&>)
2023-12-10 22:05:32 +0000 <yahb2> *** Parser [source]: ; !!! Parser [source]: finished in 0.11 milliseconds, allocated 0.035 megabytes ; ; <interactive>:1:1: error: ; Not in scope: data constructor ‘Data.Functor’ ; No modu...
2023-12-10 22:05:35 +0000 <ski> Celestial : and yea, `IORef', if you don't particularly care about transactions, you only care about swapping out single `IORef's at a time
2023-12-10 22:05:52 +0000 <ski> % :t (Data.Functor.<&>)
2023-12-10 22:05:52 +0000 <yahb2> *** Parser [source]: ; !!! Parser [source]: finished in 0.08 milliseconds, allocated 0.030 megabytes ; (Data.Functor.<&>) :: Functor f => f a -> (a -> b) -> f b
2023-12-10 22:05:57 +0000 <jackdk> anyway : (<&>) :: Functor f => f a -> (a -> b) -> f b
2023-12-10 22:06:07 +0000 <ski> % :q
2023-12-10 22:06:07 +0000 <yahb2> <bye>
2023-12-10 22:06:09 +0000 <ski> % :t (Data.Functor.<&>)
2023-12-10 22:06:09 +0000 <yahb2> (Data.Functor.<&>) :: Functor f => f a -> (a -> b) -> f b
2023-12-10 22:06:23 +0000 <haskellbridge> 12<C​elestial> ski: Thank you!
2023-12-10 22:06:35 +0000 <ski> Celestial : see what EvanR and monochrom said
2023-12-10 22:09:39 +0000 <haskellbridge> 12<C​elestial> Okay I think I understand
2023-12-10 22:09:50 +0000 <haskellbridge> 12<C​elestial> still new to concurrency with haskell
2023-12-10 22:09:58 +0000 <haskellbridge> 12<C​elestial> so thank you for the help everyone+
2023-12-10 22:12:44 +0000 <ski> Celestial : btw, `Array (Either i j) e' is not allowed, because `Ix' allows you to use subranges (intervals) of the index type. for `Int', such an interval `{i | lo =< i =< hi}' is expressed by the bounds `(lo,hi)'
2023-12-10 22:12:51 +0000 <ski> for `(Int,Int)', an interval `{(i0,i1) | (lo0,lo1) =< (i0,i1) =< (hi0,hi1)}', iow `{(i0,i1) | lo0 =< i0 =< hi0,lo1 =< i1 =< hi1}' (note this is not the usual lexcographic (total) ordering you get with `Ord (Int,Int)', rather `Ix (Int,Int)' is the product partial ordering. `range' enumerates the interval lexicographically, though)
2023-12-10 22:19:11 +0000 <EvanR> =< ?
2023-12-10 22:19:15 +0000 <EvanR> :t (=<)
2023-12-10 22:19:16 +0000 <lambdabot> error:
2023-12-10 22:19:16 +0000 <lambdabot> • Variable not in scope: =<
2023-12-10 22:19:16 +0000 <lambdabot> • Perhaps you meant one of these:
2023-12-10 22:19:21 +0000 <ski> such an interval is expressed by the bounds `((lo0,lo1),(hi0,hi1))' (this is a generalized kind of interval, as defined in order theory. in this case, it's a "rectangle")
2023-12-10 22:19:57 +0000 <ski> (for math, i prefer `<',`=<',`>=',`>' (as Prolog and Erlang does it), preferring `<=' as leftwards implication)
2023-12-10 22:20:20 +0000 <ski> @let data Word2 = W0 | W1 | W2 | W3 deriving (Read,Show,Eq,Ord,Enum,Bounded,Ix)
2023-12-10 22:20:21 +0000 <lambdabot> Defined.
2023-12-10 22:20:24 +0000 <ski> > [i | i <- [minBound .. maxBound],W1 <= i,i <= W2]
2023-12-10 22:20:26 +0000 <lambdabot> [W1,W2]
2023-12-10 22:20:31 +0000 <ski> > [i | i <- [minBound .. maxBound],inRange (W1,W2) i]
2023-12-10 22:20:32 +0000 <lambdabot> [W1,W2]
2023-12-10 22:20:37 +0000 <ski> > [i | i <- range (W1,W2)]
2023-12-10 22:20:41 +0000 <lambdabot> [W1,W2]
2023-12-10 22:20:46 +0000 <ski> > [(i,j) | [i,j] <- replicateM 2 [minBound .. maxBound],(W1,W1) <= (i,j),(i,j) <= (W2,W2)]
2023-12-10 22:20:47 +0000 <lambdabot> [(W1,W1),(W1,W2),(W1,W3),(W2,W0),(W2,W1),(W2,W2)]
2023-12-10 22:20:55 +0000 <ski> > [(i,j) | [i,j] <- replicateM 2 [minBound .. maxBound],inRange ((W1,W1),(W2,W2)) (i,j)]
2023-12-10 22:20:57 +0000 <lambdabot> [(W1,W1),(W1,W2),(W2,W1),(W2,W2)]
2023-12-10 22:21:01 +0000Sgeo(~Sgeo@user/sgeo)
2023-12-10 22:21:02 +0000 <ski> > [(i,j) | (i,j) <- range ((W1,W1),(W2,W2))]
2023-12-10 22:21:03 +0000 <lambdabot> [(W1,W1),(W1,W2),(W2,W1),(W2,W2)]
2023-12-10 22:21:50 +0000 <ski> notice how these last two express the "middle square" (an interval), bounded by `(W1,W1)' and `(W2,W2)', not containing any `W0's or `W3's
2023-12-10 22:23:05 +0000 <ski> while the one before those two, using the ordinary lexicographical order (`Ord (Integer,Integer)'), does "bleed over" into the remainder of the first row, and the start of the second row, before reaching the endpoint, so includes `W0's and `W3's
2023-12-10 22:23:56 +0000puke(~puke@user/puke) (Quit: puke)
2023-12-10 22:26:57 +0000 <ski> so .. for `Ix (Either i j)', we'd arguably need both a lower&upper bound for the `i'-indexed part of the array, and a lower&upper bound for the `j'-indexed part of the array (since `Array (Either i j) e' presumably then ought to correspond to `(Array i e,Array j e)', one array part indexed by `i', and another by `j'). so the bounds type would probably be `((i,j),(i,j))', then
2023-12-10 22:26:57 +0000 <cheater> ski: yes
2023-12-10 22:27:06 +0000 <cheater> ski: do they exist?
2023-12-10 22:27:21 +0000 <ski> but what the types give us is `(Either i j,Either i j)', either a lower bound for `i' or one for `j', and likewise for upper bound
2023-12-10 22:29:40 +0000 <ski> (one could argue that `Array (Either i i) e' ought to be equivalent to `Array (Bool,i) e', which would then use the partial ordering `Ix (Bool,i)' to express either an interval within the first `i'-indexed array, or either one within the second, or two "parallel" ones, with the same `i' bounds, within both. but for `Array (Either i j) e', `i' and `j' are not known to be related, so one can't expect such
2023-12-10 22:29:46 +0000 <ski> "synchronized" indexing for both parts there)
2023-12-10 22:29:50 +0000__monty__(~toonn@user/toonn) (Quit: leaving)
2023-12-10 22:30:08 +0000[_](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 22:31:11 +0000Volt_(~Volt_@c-73-47-181-152.hsd1.ma.comcast.net)
2023-12-10 22:32:49 +0000puke(~puke@user/puke)
2023-12-10 22:33:16 +0000waleee(~waleee@h-176-10-144-38.NA.cust.bahnhof.se) (Ping timeout: 245 seconds)
2023-12-10 22:33:41 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470) (Ping timeout: 245 seconds)
2023-12-10 22:39:23 +0000newsham(~newsham@2603-800c-2c01-6825-857b-69b9-29f4-97e6.res6.spectrum.com) (Quit: Client closed)
2023-12-10 22:40:24 +0000waleee(~waleee@176.10.144.38)
2023-12-10 22:43:13 +0000 <ski> cheater : they exist in OCaml <https://v2.ocaml.org/manual/patterns.html#sss:pat-or>, in SML/NJ <https://www.smlnj.org/doc/features.html>. <http://rosettacode.org/wiki/Pattern_matching#OCaml> has an example of their use, in OCaml (balancing red-black trees)
2023-12-10 22:43:23 +0000 <cheater> thanks
2023-12-10 22:44:29 +0000 <ski> as mentioned above by tromp,dminuoso_, it's also been considered for GHC
2023-12-10 22:46:02 +0000 <ski> (i think i wrote that OCaml (and Prolog) example, on that RosettaCode page, years ago)
2023-12-10 22:47:52 +0000EvanR(~EvanR@user/evanr) (Quit: Leaving)
2023-12-10 22:49:04 +0000 <Hecate> if there are people who ever shipped static ".a" archives with their haskell libraries, I'd love some insights: https://github.com/haskell/cabal/issues/9509
2023-12-10 22:49:11 +0000EvanR(~EvanR@user/evanr)
2023-12-10 23:04:01 +0000 <jackdk> I don't know about cabal but I believe that the linker must be invoked with all the necessary `-l` arguments. So I would expect a tool like cabal to have to propagate them to whatever ends up actually calling the linker
2023-12-10 23:04:17 +0000urdh(~urdh@user/urdh) (Ping timeout: 256 seconds)
2023-12-10 23:05:55 +0000aztex(~aztex@178.197.239.241)
2023-12-10 23:06:28 +0000 <aztex> Hey I have a Haskell project and I would like to trace the function calls that are made
2023-12-10 23:06:45 +0000 <aztex> could you point me to some documentation on this
2023-12-10 23:07:01 +0000 <EvanR> you can use Debug.Trace pretty easily to trace what expressions are evaluated
2023-12-10 23:07:22 +0000 <aztex> I am thinking about runtime tracing
2023-12-10 23:07:25 +0000 <EvanR> me too
2023-12-10 23:07:28 +0000 <idgaen> Hecate: debian shipped their haskell libraries with .a (and not .so)
2023-12-10 23:07:40 +0000 <aztex> where the programmer doesn't need to manually call "trace"
2023-12-10 23:08:05 +0000 <aztex> I think with Debug.Trace the programmer has to annotate the information that they are tracing
2023-12-10 23:08:23 +0000 <EvanR> yes it prints something out what a selected expression is evaluated
2023-12-10 23:08:24 +0000 <aztex> what I am wondering is whether the RTS has some information on the function calls being made
2023-12-10 23:08:27 +0000 <EvanR> when*
2023-12-10 23:08:40 +0000 <aztex> like some kind of profiling
2023-12-10 23:09:13 +0000 <monochrom> Well then you read the GHC User's Guide for its debugger.
2023-12-10 23:09:47 +0000gmg(~user@user/gehmehgeh) (Quit: Leaving)
2023-12-10 23:09:52 +0000 <haskellbridge> 12<C​elestial> how is trace implemented? Is it just an `unsafePerformIO . putStrLn`?
2023-12-10 23:10:22 +0000 <monochrom> Yeah. In fact it calls a C function, so as not to disturb RTS's stdout and stderr. :)
2023-12-10 23:10:48 +0000 <aztex> https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Debug.Trace.html#trace
2023-12-10 23:10:58 +0000 <EvanR> unsafePerformIO . debugBelch xD
2023-12-10 23:13:23 +0000aztex(~aztex@178.197.239.241) (Quit: Client closed)
2023-12-10 23:14:27 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net)
2023-12-10 23:16:16 +0000 <idgaen> Oh! I'm wrong, in debian there is also .so files.
2023-12-10 23:17:59 +0000bitdex(~bitdex@gateway/tor-sasl/bitdex)
2023-12-10 23:18:22 +0000acidjnk_new(~acidjnk@p200300d6e72b93299103c78233b0ca81.dip0.t-ipconnect.de) (Ping timeout: 256 seconds)
2023-12-10 23:19:28 +0000tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2023-12-10 23:19:58 +0000nate4(~nate@c-98-45-158-125.hsd1.ca.comcast.net) (Ping timeout: 255 seconds)
2023-12-10 23:21:09 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:d128:ce35:54e1:65e2) (Remote host closed the connection)
2023-12-10 23:24:54 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com) (Quit: peterbecich)
2023-12-10 23:25:12 +0000idgaen(~idgaen@2a01:e0a:498:fd50:fcc6:bb5d:489a:ce8c) (Quit: WeeChat 4.1.1)
2023-12-10 23:25:34 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com)
2023-12-10 23:27:34 +0000 <tri> hi folks, * -> * is considered a higher-kinded type right? And iirc, it's called first-order type
2023-12-10 23:27:53 +0000 <dibblego> it's the notation of the type of a higher-kinded type
2023-12-10 23:29:08 +0000 <tri> so Person a = Person a is a higher kinded type
2023-12-10 23:29:40 +0000 <tri> so then, F# and C# do have HKT with generic, just that they stop at the first-order type
2023-12-10 23:30:22 +0000 <dibblego> No.
2023-12-10 23:30:30 +0000 <dibblego> the type of Person is * -> *
2023-12-10 23:30:41 +0000 <dibblego> also called "the kind of Person"
2023-12-10 23:30:54 +0000 <dibblego> the kind of Maybe is * -> *
2023-12-10 23:31:02 +0000 <dibblego> you could find this out in ghci with :kind Maybe
2023-12-10 23:31:28 +0000 <tri> right, but didn't you just said it's the notation of the type of a HKT?
2023-12-10 23:31:30 +0000 <geekosaur> a higher-kinded type is something like `data Foo f = Foo (f Int)`, which means `f` has kind * -> *
2023-12-10 23:31:49 +0000 <dibblego> yes, * -> * will be the result, it is notating the kind of Maybe back to you
2023-12-10 23:32:22 +0000 <dibblego> here is another example: https://i.imgur.com/I0XFRWf.png
2023-12-10 23:33:37 +0000 <tri> dibblego: i understand the kind of Maybe and Person is * -> *
2023-12-10 23:33:47 +0000 <tri> but isn't * -> * HKT?
2023-12-10 23:34:33 +0000 <dibblego> not exactly, since I could say, write the Maybe type in C#, and it would have that kind, but that is not to say C# permits HKT
2023-12-10 23:34:37 +0000 <tri> geekosaur: sorry that just went over my head
2023-12-10 23:35:01 +0000 <dibblego> @type \a b -> const a <$> b
2023-12-10 23:35:02 +0000 <lambdabot> Functor f => b1 -> f b2 -> f b1
2023-12-10 23:35:10 +0000 <tri> geekosaur: i understand your example, but at the same time kinda confused as i have never seen it before
2023-12-10 23:35:10 +0000 <dibblego> I cannot write the type of this function in C#
2023-12-10 23:35:10 +0000[itchyjunk](~itchyjunk@user/itchyjunk/x-7353470)
2023-12-10 23:35:14 +0000 <dibblego> it does not have HKT
2023-12-10 23:37:26 +0000peterbecich(~Thunderbi@047-229-123-186.res.spectrum.com) (Ping timeout: 245 seconds)
2023-12-10 23:38:13 +0000 <tri> dibblego: yea that example just went over my head. I know const drop the second argument and return the first one. But you applied 3 args there, and the fact that you used fmap as a second arg just blew my mind
2023-12-10 23:38:34 +0000 <tri> welp, i will just re-read HKT again
2023-12-10 23:38:46 +0000[_](~itchyjunk@user/itchyjunk/x-7353470) (Ping timeout: 256 seconds)
2023-12-10 23:38:52 +0000 <dibblego> I don't have a C# compiler handy, but what is the type of this expression? (a, b) => from _ <- b; select a;
2023-12-10 23:39:10 +0000alexherbo2(~alexherbo@2a02-8440-3140-cd78-e0d9-a0e2-1a64-1fd2.rev.sfr.net) (Ping timeout: 250 seconds)
2023-12-10 23:39:45 +0000 <tri> i dont think from _ <-b is a valid c# syntax, what are you trying to do there?
2023-12-10 23:39:55 +0000 <dibblego> yeah it is
2023-12-10 23:40:06 +0000 <dibblego> (a, b) => b.Select(_ => a);
2023-12-10 23:40:07 +0000 <tri> is that linq? i never use linq sql like that
2023-12-10 23:40:09 +0000 <dibblego> same thing ^^
2023-12-10 23:40:09 +0000 <tri> oh ok
2023-12-10 23:40:21 +0000 <dibblego> what is its type?
2023-12-10 23:40:23 +0000 <tri> yea sorry never write linq that way in my life, ok let me read that again
2023-12-10 23:40:45 +0000 <tri> so b must be an IEnumerable
2023-12-10 23:40:50 +0000 <dibblego> must it?
2023-12-10 23:40:55 +0000 <tri> cuz of Select
2023-12-10 23:41:05 +0000 <tri> and a could be anythign
2023-12-10 23:41:08 +0000 <dibblego> what about the other things that have Select, but are not IEnumerable?
2023-12-10 23:41:25 +0000 <tri> hm idk off the top of my head
2023-12-10 23:41:36 +0000 <dibblego> well, is it the type of those things as well?
2023-12-10 23:41:37 +0000 <tri> oh
2023-12-10 23:41:48 +0000 <dibblego> I know quite a few things that have Select, but are not IEnumerable
2023-12-10 23:41:51 +0000 <tri> IQueryable
2023-12-10 23:41:54 +0000 <dibblego> can it be those as well?
2023-12-10 23:42:30 +0000eggplantade(~Eggplanta@2600:1700:38c5:d800:d128:ce35:54e1:65e2)
2023-12-10 23:42:31 +0000 <tri> ok so your point is, b and a could be many things
2023-12-10 23:42:38 +0000 <dibblego> yes, but not just anything
2023-12-10 23:42:48 +0000 <tri> b is limited to interfaces/classes that have select
2023-12-10 23:42:50 +0000 <dibblego> more specifically, "b can be anything that as Select"
2023-12-10 23:42:53 +0000 <dibblego> right
2023-12-10 23:42:55 +0000 <tri> while a could be anything
2023-12-10 23:42:56 +0000 <dibblego> now write that interface
2023-12-10 23:43:02 +0000 <dibblego> you will need HKT to do this
2023-12-10 23:43:16 +0000 <dibblego> did you do it with C# ?
2023-12-10 23:43:22 +0000Tuplanolla(~Tuplanoll@91-159-68-236.elisa-laajakaista.fi) (Ping timeout: 255 seconds)
2023-12-10 23:43:43 +0000 <tri> no i didn't but i guess it would not let me
2023-12-10 23:43:56 +0000 <tri> but if i were to write it in Haskell
2023-12-10 23:44:01 +0000 <tri> that could probably look like
2023-12-10 23:44:02 +0000 <dibblego> it might, if C# had HKT
2023-12-10 23:44:09 +0000 <dibblego> we could try...
2023-12-10 23:44:34 +0000 <tri> Selectable b => a -> b -> a
2023-12-10 23:44:46 +0000 <dibblego> that's not quite right is it
2023-12-10 23:44:51 +0000 <dibblego> also, you need to write Selectable
2023-12-10 23:45:08 +0000 <tri> yea the return is not right, since b is of a "collection" tyope
2023-12-10 23:45:21 +0000 <dibblego> here is an invented of C#, with a slight change
2023-12-10 23:45:39 +0000 <dibblego> Selectable<F<_>> => a -> F<b> -> F<a>
2023-12-10 23:45:55 +0000 <dibblego> this is not real syntax of course
2023-12-10 23:46:05 +0000 <dibblego> it's maybe what it might look like, if C# had HKT
2023-12-10 23:46:18 +0000 <dibblego> Selectable exists in Haskell, because Haskell has HKT
2023-12-10 23:46:21 +0000coot(~coot@89-69-206-216.dynamic.chello.pl) (Quit: coot)
2023-12-10 23:46:22 +0000 <dibblego> its name is different though
2023-12-10 23:46:26 +0000 <dibblego> it's called Functor instead
2023-12-10 23:46:34 +0000 <dibblego> @type \a b -> const a <$> b
2023-12-10 23:46:35 +0000 <lambdabot> Functor f => b1 -> f b2 -> f b1
2023-12-10 23:46:54 +0000 <tri> oh i remember someone said that * -> * -> * is like generics of T<A,B>, which .NET can support
2023-12-10 23:47:10 +0000 <dibblego> * -> * -> * is notation for the type of T
2023-12-10 23:47:17 +0000 <tri> but .NET can't support (* -> *) -> * which is T<A<B>>, which is what you just did right
2023-12-10 23:47:24 +0000 <tri> im just parroting what i remember
2023-12-10 23:47:28 +0000 <dibblego> but we cannot use anything with that type, unless it is fully applied, because C# (and F#) do not have HKT
2023-12-10 23:47:55 +0000 <dibblego> "IEnumerable" has a type, and that type is, "given a type, return a type"
2023-12-10 23:48:07 +0000 <tri> yea that's generic, *->*
2023-12-10 23:48:09 +0000 <dibblego> but we cannot use that thing, we cannot express it
2023-12-10 23:48:21 +0000 <glguy> tri: assuming A takes one type parameter, (* -> *) -> * would be like: T<A> where A's types are not provided
2023-12-10 23:48:28 +0000 <dibblego> more practically, we cannot write this type:
2023-12-10 23:48:29 +0000 <dibblego> @type \a b -> const a <$> b
2023-12-10 23:48:30 +0000 <lambdabot> Functor f => b1 -> f b2 -> f b1
2023-12-10 23:49:14 +0000 <glguy> type T c = (c Int, c Bool) -- like if you wanted to T to be parameterized by a container type and then use that container to contain two different kinds of elements
2023-12-10 23:49:40 +0000 <tri> I still can't wrap my head over const a <$> b. I always think that const only take 2 args. 3 args there throws me off
2023-12-10 23:50:20 +0000 <glguy> <$> isn't an argument to const
2023-12-10 23:50:33 +0000 <dibblego> @type \a b -> fmap (const a) b -- same thing
2023-12-10 23:50:34 +0000 <lambdabot> Functor f => b1 -> f b2 -> f b1
2023-12-10 23:51:01 +0000 <tri> oh ok, i need some time to read these again
2023-12-10 23:52:57 +0000 <tri> @kind \a b -> const a <$> b
2023-12-10 23:52:58 +0000 <lambdabot> error: parse error on input ‘\’
2023-12-10 23:53:48 +0000 <glguy> @type \a b -> const a <$> b
2023-12-10 23:53:49 +0000 <lambdabot> Functor f => b1 -> f b2 -> f b1
2023-12-10 23:55:20 +0000 <probie> > const (*2) (+1) 5 -- Although, `const` can have "3 args", depending on how you count arguments
2023-12-10 23:55:21 +0000 <lambdabot> 10
2023-12-10 23:56:13 +0000 <tri> ok............
2023-12-10 23:56:23 +0000 <tri> i gotta re-read HKT
2023-12-10 23:56:39 +0000 <tri> thank you everyone
2023-12-10 23:58:33 +0000 <EvanR> const takes 1 args
2023-12-10 23:58:50 +0000 <tri> btw thanks probie and EvnR