Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-01 21:04:39 × Pickchea quits (~private@unaffiliated/pickchea) (Quit: Leaving)
2021-04-01 21:04:51 <xaltsc> "math, linear algebra, always has been" meme
2021-04-01 21:05:47 × sdrodge quits (~sdrodge@unaffiliated/sdrodge) (Ping timeout: 265 seconds)
2021-04-01 21:05:47 <electricityZZZZ> i have written a few somewhat nontrivial "programs" in elm and feel reasonably comfortable with that language. i might entertain the idea that i understand the language "to completion". is there some kind of haskell subset i can reasonably "completely understand"?
2021-04-01 21:06:10 <maerwald> electricityZZZZ: haskell2010
2021-04-01 21:06:26 × takuan quits (~takuan@178-116-218-225.access.telenet.be) (Remote host closed the connection)
2021-04-01 21:06:58 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds)
2021-04-01 21:08:50 × segut quits (49f18bf8@c-73-241-139-248.hsd1.ca.comcast.net) (Quit: Connection closed)
2021-04-01 21:12:52 × _fcntl quits (~jaroslawj@185.234.208.208.r.toneticgroup.pl) (Quit: Lost terminal)
2021-04-01 21:15:23 coot joins (~coot@37.30.55.131.nat.umts.dynamic.t-mobile.pl)
2021-04-01 21:18:06 × Erutuon_ quits (~Erutuon@97-116-27-119.mpls.qwest.net) (Ping timeout: 240 seconds)
2021-04-01 21:20:25 Erutuon_ joins (~Erutuon@97-116-27-119.mpls.qwest.net)
2021-04-01 21:21:51 × Varis quits (~Tadas@unaffiliated/varis) (Remote host closed the connection)
2021-04-01 21:22:31 × graf_blu` quits (~user@adsl-178-38-234-220.adslplus.ch) (Remote host closed the connection)
2021-04-01 21:25:38 × zebrag quits (~inkbottle@aaubervilliers-654-1-98-245.w86-212.abo.wanadoo.fr) (Quit: Konversation terminated!)
2021-04-01 21:25:59 zebrag joins (~inkbottle@aaubervilliers-654-1-98-245.w86-212.abo.wanadoo.fr)
2021-04-01 21:28:41 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-04-01 21:29:34 <moet> is there a haskell library for mutating subarrays in a large multidimensional array? repa and hmatrix don't seem to support a way to put slices (references to submatrixes) back into the original structure w/o large copies
2021-04-01 21:30:14 nut joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr)
2021-04-01 21:31:17 × malumore_ quits (~malumore@151.62.112.245) (Remote host closed the connection)
2021-04-01 21:31:56 × fendor quits (~fendor@91.141.3.64.wireless.dyn.drei.com) (Remote host closed the connection)
2021-04-01 21:32:03 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Client Quit)
2021-04-01 21:32:25 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-04-01 21:33:14 <nut> Will runST break purity? Immutable in, immutable out, but in between there's side effect
2021-04-01 21:33:35 <moet> nut: runST breaks the rules around purity; it hides impure stuff internally
2021-04-01 21:33:57 <moet> nut: i believe it uses runtime facilities to accomplish this
2021-04-01 21:34:20 <nut> myfunction :: Vec -> Vec
2021-04-01 21:34:33 <nut> for this function, if i use runST on Vec
2021-04-01 21:34:42 <nut> then it looks pure, but it's not
2021-04-01 21:34:43 <dolio> It doesn't break rules.
2021-04-01 21:35:29 <nut> I mean, there seems to be side effect to this seemingly pure function
2021-04-01 21:35:31 <moet> nut: you can't really use runST inside that function because runST relies on a type parameter `s` which isn't present in your return type.. it would have to be contained (foralled) inside your Vec or something, but i don't think that's possible.. the whole point of that parameter is to prevent the impurity from escaping
2021-04-01 21:36:13 <nut> I understand that no immutable things will get out
2021-04-01 21:36:33 <moet> i might be getting confused here actually; you can do that; the `s` is contained inside the action to runST
2021-04-01 21:36:51 <nut> but if Vec is immutable, then myfunction is a pure function no?
2021-04-01 21:37:11 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 240 seconds)
2021-04-01 21:38:00 × haritz quits (~hrtz@unaffiliated/haritz) (Quit: ZNC 1.7.2+deb3 - https://znc.in)
2021-04-01 21:38:37 <monochrom> Let me cut to the mustard. How do you observe "side effect"?
2021-04-01 21:38:38 <nut> https://pastebin.com/2m4knwzU
2021-04-01 21:38:39 <nut> Could anyone take a look at this if it's pure?
2021-04-01 21:38:49 <monochrom> If you can't observe it then it didn't happen.
2021-04-01 21:39:44 <nut> The input is a vector, and within the runST, i first turn it into mutable vector, then modify it, then freeze it
2021-04-01 21:39:48 <nut> then return
2021-04-01 21:40:03 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-04-01 21:40:09 <int-e> nut: `thaw` will make a copy
2021-04-01 21:40:18 × guest3546456 quits (~jaroslawj@185.234.208.208.r.toneticgroup.pl) (Quit: leaving)
2021-04-01 21:40:28 <nut> aha
2021-04-01 21:40:30 <nut> i see now
2021-04-01 21:40:39 <moet> nut: i looked at your function; it's pure from the external perspective, but it's returning a copy as int-e said
2021-04-01 21:40:55 <monochrom> freeze makes one more copy
2021-04-01 21:41:05 <nut> i get it guys, thx
2021-04-01 21:41:16 <monochrom> I thought you knew from the docs.
2021-04-01 21:41:44 <nut> i just got lost for a moment
2021-04-01 21:42:02 <nut> new to the ST Monad
2021-04-01 21:42:06 <moet> nut: you might be better off writing your domain functions in terms of `ST s Returntype` and then you can combine them all near the top level with `runST` and then you'll get a speedy implementation with less copies
2021-04-01 21:43:03 <nut> Great tip
2021-04-01 21:43:27 × RusAlex quits (~Chel@unaffiliated/rusalex) (Ping timeout: 252 seconds)
2021-04-01 21:43:33 <int-e> hmm, does vector have an analog of `runSTArray` that wraps unsafeFreeze safely?
2021-04-01 21:43:35 <nut> moet: when I'm more comfortable with the APIs I will do that. I'm learning both vectors and ST now
2021-04-01 21:43:55 <monochrom> I think no.
2021-04-01 21:44:06 × mrd quits (~mrd@debian/developer/mrd) (Ping timeout: 246 seconds)
2021-04-01 21:44:36 <nut> that runSTArray also confuses me, because there's vectors and arrays which seem similar
2021-04-01 21:44:52 mrd joins (~mrd@45.61.147.211)
2021-04-01 21:45:16 mrd is now known as Guest40940
2021-04-01 21:45:42 molehillish joins (~molehilli@2600:8800:8d06:1800:49e2:dd02:cb68:846)
2021-04-01 21:46:22 <koz_> nut: vector-the-library is a layer on top of arrays.
2021-04-01 21:46:31 <koz_> It's designed to be more convenient and feature-ful.
2021-04-01 21:46:46 <nut> i see
2021-04-01 21:47:00 haritz joins (~hrtz@2a02:8010:65b5:0:6009:6384:e3cb:2220)
2021-04-01 21:47:00 × haritz quits (~hrtz@2a02:8010:65b5:0:6009:6384:e3cb:2220) (Changing host)
2021-04-01 21:47:00 haritz joins (~hrtz@unaffiliated/haritz)
2021-04-01 21:47:20 RusAlex joins (~Chel@unaffiliated/rusalex)
2021-04-01 21:47:28 <nut> So can I understand that ST is an escape to the imperative world?
2021-04-01 21:47:34 <koz_> nut: No.
2021-04-01 21:47:47 <koz_> Read 'Functional Lazy State Threads' if you want a good explanation.
2021-04-01 21:48:27 <nut> I'll do that a bit later. I'm actually trying to implement the algolrithms from Introduction to Algorithms the book
2021-04-01 21:48:47 <nut> And I've used Haskell List for implementation before
2021-04-01 21:49:01 <nut> Which is linked list and not recomended
2021-04-01 21:49:08 <L29Ah> nut: nah it's a limited chunk of real world that lives in a jail of the pure world
2021-04-01 21:49:18 <nut> So that's why I'm looking at vectors and all that mutable stuff
2021-04-01 21:49:46 sdrodge joins (~sdrodge@unaffiliated/sdrodge)
2021-04-01 21:49:47 × Tario quits (~Tario@200.119.184.73) (Read error: Connection reset by peer)
2021-04-01 21:50:02 <koz_> I'd say 'use vector immutably' before going any further. Limits what you have to learn at least.
2021-04-01 21:50:05 Tario joins (~Tario@201.192.165.173)
2021-04-01 21:50:12 <nut> L29Ah: koz_ OK, so for my particular application, is it appropritate to make heavy use of ST monad ?
2021-04-01 21:50:24 <koz_> nut: I have no idea what your application is.
2021-04-01 21:50:33 <koz_> I would argue that first, start with immutable.
2021-04-01 21:50:38 <koz_> You'd be surprised how far that gets you.
2021-04-01 21:50:45 <nut> implement quicksort, heap sort, dynamic programming etc.
2021-04-01 21:50:56 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:d987:a6e5:6815:ac7d) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-04-01 21:51:06 <koz_> For sorting, you might wanna use ST, but here you actually have a stack of ST and random.
2021-04-01 21:51:09 <L29Ah> just make sure ST doesn't leak out to the public interface
2021-04-01 21:51:11 <koz_> Dynamic programming is a technique.
2021-04-01 21:51:17 <koz_> So I have no idea what that means either.
2021-04-01 21:51:26 <koz_> Levenstein distance is dynamic programming; so is simplex.
2021-04-01 21:51:36 <nut> for quicksort for example, there's so many inplace updates and array index moving, can i still do it with immutable vector?
2021-04-01 21:51:59 <koz_> If you're dead-set on in-place quicksort? Then it's probably better to use ST.
2021-04-01 21:52:05 <koz_> However, what's your goal?
2021-04-01 21:52:15 <koz_> Is it 'learn to implement in-place quicksort'?
2021-04-01 21:52:36 <nut> My goal is to learn both algorithm and haskel

All times are in UTC.