Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-19 06:37:17 Stanley00 joins (~stanley00@unaffiliated/stanley00)
2020-11-19 06:37:18 <MarcelineVQ> for what?
2020-11-19 06:37:28 <n0042> To simulate a Queue, or circular buffer
2020-11-19 06:38:03 <dsal> Lists are fine for many of these things, but there are specific structures.
2020-11-19 06:40:45 <zyklotomic> is it a bad practice to append to the front of a list instead tehn
2020-11-19 06:40:50 <zyklotomic> to get around the time complexity of ++
2020-11-19 06:40:56 <dsal> It's the best.
2020-11-19 06:41:01 <n0042> Seems like the opposite. Bad practice to append to the rear
2020-11-19 06:41:04 <dsal> No better place to put something.
2020-11-19 06:41:13 <dsal> ++ is another one of those language warts.
2020-11-19 06:41:21 <MarcelineVQ> lists make pretty good queues in haskell https://rafal.io/posts/haskell-queues.html
2020-11-19 06:41:55 <zyklotomic> dsal: so lists make a pretty bad monoid?
2020-11-19 06:41:58 <MarcelineVQ> This doesn't explain super in depth, but the idea is to use two lists with one in reverse to create your queue
2020-11-19 06:42:15 <dsal> zyklotomic: ++ vs. <>
2020-11-19 06:42:19 <n0042> Thank you very much
2020-11-19 06:42:22 <dsal> lists are fine for what they do
2020-11-19 06:42:23 mceier joins (~mceier@89-68-132-187.dynamic.chello.pl)
2020-11-19 06:42:47 shangxiao joins (~davids@101.181.159.140)
2020-11-19 06:43:21 <MarcelineVQ> There's a lot of queue-like things around though so you'd probably just want to use whatever and optommize later, Seq that dsal mentioned is a fair all-around option for accessing either end of.
2020-11-19 06:44:02 <n0042> Oh wow, Haskell has built-ins for everything
2020-11-19 06:44:12 <dsal> built-in?
2020-11-19 06:44:52 <n0042> Stuff you don't have to roll on your own.
2020-11-19 06:45:02 <MarcelineVQ> dsal: people who don't already know don't know what you mean when you say you don't like map and ++. They won't realize you mean you don't like that there's both fmap and map and just want one, or relatedly that ++ and <> are the same for lists so just <> is fine
2020-11-19 06:45:12 <dsal> Oh. Not built-in, just already implemented..
2020-11-19 06:45:22 <n0042> Yes, thank you
2020-11-19 06:45:35 Stanley|00 joins (~stanley00@unaffiliated/stanley00)
2020-11-19 06:45:46 <dsal> MarcelineVQ: that's true. People should understand me better. heh
2020-11-19 06:46:02 <n0042> You've both been very helpful, thank you.
2020-11-19 06:46:24 × jlamothe quits (~jlamothe@198.251.55.207) (Ping timeout: 260 seconds)
2020-11-19 06:46:48 <dsal> The functional data structure stuff is amazing. That queue thing was amazing to see.
2020-11-19 06:47:34 <zyklotomic> MarcelineVQ: wait, I don't think ++ and <> are the same
2020-11-19 06:47:41 <dsal> :t (++)
2020-11-19 06:47:42 <lambdabot> [a] -> [a] -> [a]
2020-11-19 06:47:44 <dsal> :t (<>)
2020-11-19 06:47:45 <lambdabot> Semigroup a => a -> a -> a
2020-11-19 06:47:49 <MarcelineVQ> The okasaki paper is a bit of a hard read if you're new to it all but it's pretty great, interesting how little progress there's been since it at as well
2020-11-19 06:47:51 <zyklotomic> which was what dsal meant
2020-11-19 06:48:10 <dsal> ++ doesn't need to exist in Haskell. Or, perhaps, <> should be ++
2020-11-19 06:48:17 <dsal> Same as map vs. fmap
2020-11-19 06:48:56 × Stanley00 quits (~stanley00@unaffiliated/stanley00) (Ping timeout: 240 seconds)
2020-11-19 06:49:04 <MarcelineVQ> Where your Semigroup is [a] then <> = ++
2020-11-19 06:49:33 <zyklotomic> <> should be ++ i think
2020-11-19 06:49:43 <zyklotomic> ++ looks more natural
2020-11-19 06:50:02 <zyklotomic> idk about fmap vs map though if you had to pick one of the two
2020-11-19 06:50:15 × Stanley|00 quits (~stanley00@unaffiliated/stanley00) (Remote host closed the connection)
2020-11-19 06:50:30 <dsal> Sure. It's just one of those things that is too much legacy code.
2020-11-19 06:50:31 <zyklotomic> MarcelineVQ: I meant the implementation, I'm not sure if they behave the same
2020-11-19 06:50:40 <zyklotomic> I get that they're isomorphic
2020-11-19 06:50:50 Stanley00 joins (~stanley00@unaffiliated/stanley00)
2020-11-19 06:50:53 <dsal> How could they behave differently?
2020-11-19 06:50:53 <zyklotomic> mconcat xss = [x | xs <- xss, x <- xs]
2020-11-19 06:51:05 <zyklotomic> (++) [] ys = ys
2020-11-19 06:51:07 <zyklotomic> (++) (x:xs) ys = x : xs ++ ys
2020-11-19 06:51:19 <dsal> @quick \l1 l2 -> (l1 ++ l2) === (l1 <> l2)
2020-11-19 06:51:19 <lambdabot> Not enough privileges
2020-11-19 06:51:31 <dsal> @check \l1 l2 -> (l1 ++ l2) === (l1 <> l2)
2020-11-19 06:51:33 <lambdabot> +++ OK, passed 100 tests.
2020-11-19 06:51:33 <MarcelineVQ> That is the implementation :> http://hackage.haskell.org/package/base-4.14.0.0/docs/src/GHC.Base.html#line-306
2020-11-19 06:52:00 <zyklotomic> my bad im barking up the wrong tree
2020-11-19 06:52:12 <zyklotomic> I looked into Data.Monoid
2020-11-19 06:53:48 <zyklotomic> wait so that wasnt disagreeing with lists being a somewhat inefficient monoid then
2020-11-19 06:54:05 <n0042> So when I asked about lists with tail-pointers dsal said "There are many, many reasons you can't do that." I have implemented a few linked lists in C and I've done some LISPing, but I'm far from an expert. I would be interested in hearing some of those reasons. Is it a performance thing, from the days of yore? Thanks again for answering my
2020-11-19 06:54:05 <n0042> questions. You folks are all very helpful.
2020-11-19 06:54:57 <n0042> I've learned more just hanging out in here for an hour than in the last two days combined. You guys are great.
2020-11-19 06:55:37 <glguy> n0042, the issue is that things aren't mutable, so you can't use a reference to the last element to add to the end of a list
2020-11-19 06:56:04 <glguy> Unless you build a mutable structure explicitly with mutable references that's accessed using IO actions
2020-11-19 06:56:27 mananamenos joins (~mananamen@84.122.202.215.dyn.user.ono.com)
2020-11-19 06:56:56 × bliminse quits (~bliminse@host109-156-197-211.range109-156.btcentralplus.com) (Ping timeout: 240 seconds)
2020-11-19 06:57:25 <zyklotomic> I was also thinking, what about [1..]
2020-11-19 06:58:00 × zebrag quits (~inkbottle@aaubervilliers-654-1-104-55.w86-212.abo.wanadoo.fr) (Quit: Konversation terminated!)
2020-11-19 06:58:02 × borne quits (~fritjof@200116b864eda200f1dc39039d201adf.dip.versatel-1u1.de) (Ping timeout: 260 seconds)
2020-11-19 06:58:04 <dsal> let a = 1:a in take 5 a
2020-11-19 06:58:09 bliminse joins (~bliminse@host109-156-197-211.range109-156.btcentralplus.com)
2020-11-19 06:58:10 <dsal> > let a = 1:a in take 5 a
2020-11-19 06:58:12 <lambdabot> [1,1,1,1,1]
2020-11-19 06:59:17 <dsal> > let a = 'x':a in length a
2020-11-19 06:59:24 <lambdabot> mueval: ExitFailure 1
2020-11-19 06:59:29 <dsal> boo. Too many exes.
2020-11-19 06:59:44 × Stanley00 quits (~stanley00@unaffiliated/stanley00) (Remote host closed the connection)
2020-11-19 07:00:10 <MarcelineVQ> how many, would you say?
2020-11-19 07:00:11 <dsal> n0042: A lot of these questions get a lot easier when you try to do the thing you think is probably easy. :)
2020-11-19 07:00:27 × alp quits (~alp@2a01:e0a:58b:4920:d4c7:761f:e715:72ea) (Ping timeout: 272 seconds)
2020-11-19 07:01:13 <n0042> That's good advice in general, for sure
2020-11-19 07:01:24 <dsal> > let a = 'x':a in take 5 (a <> "and then y")
2020-11-19 07:01:26 <lambdabot> "xxxxx"
2020-11-19 07:02:10 Stanley00 joins (~stanley00@unaffiliated/stanley00)
2020-11-19 07:02:18 <dsal> I just made a list of infinite length and appended a list to the end of it. Please adjust pointers accordingly. :)
2020-11-19 07:06:59 idhugo joins (~idhugo@80-62-116-101-mobile.dk.customer.tdc.net)
2020-11-19 07:07:11 Gurkenglas joins (~Gurkengla@unaffiliated/gurkenglas)
2020-11-19 07:08:02 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:6c29:bc9c:b97a:2b45) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-11-19 07:08:17 <n0042> Is the `<> "and then y"` part ever evaluated?
2020-11-19 07:09:02 actuallybatman joins (~sam@S010664777dafd303.cg.shawcable.net)
2020-11-19 07:09:06 <n0042> lazy evaluation is pretty wild. I'm still trying to wrap my head around that part.
2020-11-19 07:09:34 solonarv joins (~solonarv@astrasbourg-653-1-156-4.w90-6.abo.wanadoo.fr)
2020-11-19 07:09:54 × LKoen quits (~LKoen@169.244.88.92.rev.sfr.net) (Remote host closed the connection)
2020-11-19 07:10:59 <ClaudiusMaximus> n0042: it's evaluated, just enough to push it down 5 cells: (x : xs) <> ys = x : (xs <> ys) happens 5 times during the evaluation of the result, after which take drops it
2020-11-19 07:13:27 × zyklotomic quits (~ethan@unaffiliated/chocopuff) (Quit: WeeChat 2.9)
2020-11-19 07:14:52 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 260 seconds)
2020-11-19 07:15:04 × idhugo quits (~idhugo@80-62-116-101-mobile.dk.customer.tdc.net) (Quit: Leaving)
2020-11-19 07:15:40 <n0042> Yeah, I have no idea how you'd do the pointers for that. That's a mind-bender.

All times are in UTC.