Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-08 20:21:26 <nut> my algorithm needs to modify elements in an arry often, do people use mutable vectors in such situations or stick to immutable vectors?
2021-04-08 20:21:28 justanotheruser joins (~justanoth@unaffiliated/justanotheruser)
2021-04-08 20:21:52 <nut> dcbdan: ghci, the repl is a debugger
2021-04-08 20:22:25 <nut> dcbdan: https://www.youtube.com/watch?v=L7QZwH_844s&t=145s
2021-04-08 20:22:51 <nut> dcbdan: check that youtube tutorial, it's the best
2021-04-08 20:23:24 usr25 joins (~usr25@unaffiliated/usr25)
2021-04-08 20:23:47 × geekosaur quits (82650c7a@130.101.12.122) (Quit: Connection closed)
2021-04-08 20:24:03 Feuermagier joins (~Feuermagi@213.178.26.41)
2021-04-08 20:24:08 samebchase-6 joins (~samebchas@51.15.68.182)
2021-04-08 20:25:45 dave_uy48 joins (~david@108.61.193.26)
2021-04-08 20:25:47 bgamari_ joins (~bgamari@2001:470:e438::1)
2021-04-08 20:25:55 __xor joins (~xor@74.215.46.133)
2021-04-08 20:26:34 deu- joins (de@uio.re)
2021-04-08 20:26:40 <dcbdan> ahhhhh, I had no idea! that's good to know
2021-04-08 20:26:52 × deu quits (de@uio.re) (Ping timeout: 268 seconds)
2021-04-08 20:26:52 × reda quits (~niemand@unaffiliated/reda) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × Feuermagier_ quits (~Feuermagi@213.178.26.41) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × dave_uy4 quits (~david@108.61.193.26) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × bgamari quits (~bgamari@72.65.102.162) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × Eliel quits (~jojkaart@163.172.153.251) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × _xor quits (~xor@74.215.46.133) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × samebchase quits (~samebchas@51.15.68.182) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × L1Cafe quits (~L1Cafe@kydara.com) (Ping timeout: 268 seconds)
2021-04-08 20:26:53 × samebchase- quits (~samebchas@51.15.68.182) (Ping timeout: 268 seconds)
2021-04-08 20:26:55 deu- is now known as deu
2021-04-08 20:27:32 Eliel joins (~jojkaart@163.172.153.251)
2021-04-08 20:27:55 × MarcelineVQ quits (~anja@198.254.208.159) (Ping timeout: 268 seconds)
2021-04-08 20:28:05 samebchase joins (~samebchas@51.15.68.182)
2021-04-08 20:29:29 L1Cafe joins (~L1Cafe@kydara.com)
2021-04-08 20:30:15 <sm[m]> dcbdan: let us know how you get on with the one in ghci. It's not used much, perhaps it should be used more. Print statements are used a lot and there's nothing wrong with that, use Debug.Trace
2021-04-08 20:32:06 reda joins (~niemand@unaffiliated/reda)
2021-04-08 20:36:20 × coot quits (~coot@37.30.55.131.nat.umts.dynamic.t-mobile.pl) (Quit: coot)
2021-04-08 20:36:32 × solvr quits (57e3c46d@87.227.196.109) (Quit: Connection closed)
2021-04-08 20:38:15 <dcbdan> I just kinda assumed that something like Debug.Trace wouldn't exist
2021-04-08 20:38:17 acidjnk_new joins (~acidjnk@p200300d0c72b9564e895d5f110e04519.dip0.t-ipconnect.de)
2021-04-08 20:38:37 <dcbdan> since as the docs say, it isn't refer transparent
2021-04-08 20:38:49 Wuzzy joins (~Wuzzy@p5790e74f.dip0.t-ipconnect.de)
2021-04-08 20:39:13 dinciorip joins (~dincio@5.170.122.95)
2021-04-08 20:39:19 × nilof quits (~olofs@90-227-86-119-no542.tbcn.telia.com) (Ping timeout: 252 seconds)
2021-04-08 20:40:26 × pfurla_ quits (~pfurla@ool-182ed2e2.dyn.optonline.net) (Ping timeout: 240 seconds)
2021-04-08 20:40:39 nilof joins (~olofs@90-227-86-119-no542.tbcn.telia.com)
2021-04-08 20:40:52 gesties joins (a7f8ae19@167.248.174.25)
2021-04-08 20:41:37 × gesties quits (a7f8ae19@167.248.174.25) (Client Quit)
2021-04-08 20:43:09 × ddellacosta quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection)
2021-04-08 20:44:12 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed)
2021-04-08 20:44:33 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-04-08 20:45:09 fiedlr joins (~fiedlr@83.148.33.254)
2021-04-08 20:46:59 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 260 seconds)
2021-04-08 20:49:09 dpl_ joins (~dpl@77-121-78-163.chn.volia.net)
2021-04-08 20:49:31 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 268 seconds)
2021-04-08 20:51:02 × fiedlr quits (~fiedlr@83.148.33.254) (Remote host closed the connection)
2021-04-08 20:51:06 × fendor_ quits (~fendor@178.165.130.18.wireless.dyn.drei.com) (Remote host closed the connection)
2021-04-08 20:51:19 fiedlr joins (~fiedlr@83.148.33.254)
2021-04-08 20:51:25 × fiedlr quits (~fiedlr@83.148.33.254) (Remote host closed the connection)
2021-04-08 20:51:31 esph joins (~weechat@unaffiliated/esph)
2021-04-08 20:52:05 × zebrag quits (~inkbottle@aaubervilliers-654-1-2-51.w83-200.abo.wanadoo.fr) (Quit: Konversation terminated!)
2021-04-08 20:52:26 zebrag joins (~inkbottle@aaubervilliers-654-1-2-51.w83-200.abo.wanadoo.fr)
2021-04-08 20:53:14 × dpl_ quits (~dpl@77-121-78-163.chn.volia.net) (Client Quit)
2021-04-08 20:54:46 <koz_> nut: Do you have the modifications 'all at once', and then use the array immutably?
2021-04-08 20:54:53 <koz_> Are the modifications in fairly random places?
2021-04-08 20:55:02 <koz_> Or, perhaps more concretely: what are you trying to do?
2021-04-08 20:55:05 star_cloud joins (~star_clou@ec2-34-220-44-120.us-west-2.compute.amazonaws.com)
2021-04-08 20:56:02 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-04-08 20:56:03 × rond_ quits (59402191@89-64-33-145.dynamic.chello.pl) (Ping timeout: 240 seconds)
2021-04-08 20:57:12 <nut> koz_: I'm reading a string and test if characters repeat. for this the easiest is to use array of bools and toggle the flag
2021-04-08 20:57:20 pfurla joins (~pfurla@mx141.canadialed.com)
2021-04-08 20:57:32 <koz_> The solution to this is 'use a Map'.
2021-04-08 20:57:38 <koz_> Or HashMap, either or.
2021-04-08 20:57:50 <koz_> Zero arrays or mutation needed, probably faster too.
2021-04-08 20:58:19 <nut> zero arrays?
2021-04-08 20:58:26 <koz_> As in, you don't need any arrays.
2021-04-08 20:58:35 <nut> i see
2021-04-08 20:58:59 <nut> I'm just so accustomed to imperative arrays
2021-04-08 20:59:13 <koz_> Get un-accustomed.
2021-04-08 20:59:22 <koz_> You're in a different environment, it requires different tools.
2021-04-08 20:59:40 <koz_> Otherwise you'll be stuck forever in XY problem hell.
2021-04-08 21:00:17 <nut> I do realize that Data.Map could be the one because it offers O(log n) lookup and 'modification'
2021-04-08 21:00:21 <monochrom> It is possible that the mutable array of bool may be faster than the Map (balanced binary search tree). But the other way round is also possible. Perhaps benchmark them.
2021-04-08 21:00:40 <koz_> monochrom: If you use HashMap, I'll be _very_ surprised if a mutable array wins.
2021-04-08 21:00:44 <nut> by modification i mean update the Data.Map value
2021-04-08 21:00:57 <monochrom> Don't forget that you also have IntMap and unordered-container's HashMap to choose from. Moar indecisions.
2021-04-08 21:01:05 <monochrom> Also, s/Map/Set/
2021-04-08 21:01:22 <koz_> monochrom: It depends whether you wanna know which are duplicated, not whether there's a dup or not.
2021-04-08 21:01:38 <koz_> If you only need to know if dupes are present, you just use 'hashNub' and do a size comparison.
2021-04-08 21:02:08 <koz_> Either way, if confronted with either of those problems, mutable arrays aren't even the _third_ thing I'd reach for.
2021-04-08 21:02:24 <nut> wow
2021-04-08 21:02:25 abrar joins (~abrar@static-108-30-103-121.nycmny.fios.verizon.net)
2021-04-08 21:02:43 <nut> mutable vectors are a bit difficult to use
2021-04-08 21:02:46 <nut> for beginners
2021-04-08 21:02:48 <nut> at least
2021-04-08 21:02:53 <koz_> They're more involved.
2021-04-08 21:03:10 <koz_> Since you need to know a) what ST is and how to use it, and b) why GHC occasionally fails to infer stuff with runST.
2021-04-08 21:03:11 × danso quits (~dan@23-233-111-52.cpe.pppoe.ca) (Quit: WeeChat 3.0)
2021-04-08 21:03:19 <koz_> (at least b) is going away once quick-look lands)
2021-04-08 21:03:55 <koz_> a), combined with the fact that mutable arrays often don't offer any improvement in perf (and indeed can make it _worse_ sometimes) is why I don't recommend reaching for them in the first instance.
2021-04-08 21:04:06 <koz_> It's a lot of additional ceremony for.. no reason.
2021-04-08 21:04:10 <nut> Those two reasons are enough to push beginners towards Maps
2021-04-08 21:04:32 <koz_> Immutable array/vector is also a good choice in many cases.
2021-04-08 21:04:38 × hyperisco quits (~hyperisco@d192-186-117-226.static.comm.cgocable.net) (Ping timeout: 240 seconds)
2021-04-08 21:04:45 <koz_> Heck, 'generate' alone obviates the need for mutation at least half the time.

All times are in UTC.