Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,801,162 events total
2025-12-19 16:15:23 <yin> that's a categorical problem
2025-12-19 16:15:54 <yin> ;)
2025-12-19 16:16:14 <lucabtz> though it is a practical problem, generally we have words for numbers, but clearly we can't name all the real ones
2025-12-19 16:16:24 <lucabtz> we just found names for a few significant ones
2025-12-19 16:16:58 <merijn> You can if you're an ultra-finitist
2025-12-19 16:17:31 spew joins (~spew@user/spew)
2025-12-19 16:19:35 machinedgod joins (~machinedg@d75-159-126-101.abhsia.telus.net)
2025-12-19 16:20:30 <milan2> Hello, sorry to interupt you guyz. :) Do you know if short-circuit foldl' is possible?
2025-12-19 16:21:46 <geekosaur> it's not AIUI
2025-12-19 16:23:20 <milan2> geekosaur: Sorry, if you replied to me I don't know what AIUI means.
2025-12-19 16:24:13 <geekosaur> "as I understand it"
2025-12-19 16:24:45 <merijn> > foldl' f z [a,b,c]
2025-12-19 16:24:47 <lambdabot> f (f (f z a) b) c
2025-12-19 16:24:51 <geekosaur> foldr's function is given a thunk representing the rest of the list, which it can choose to not evaluate and thereby short circuit. foldl/foldl' isn't
2025-12-19 16:25:00 <merijn> Define short-circuit
2025-12-19 16:25:13 <merijn> You can certainly short-circuit, but not without walking the entire list
2025-12-19 16:25:35 <merijn> oh, wait, no, it's foldl'
2025-12-19 16:25:38 <merijn> brainfart :)
2025-12-19 16:26:05 <yin> milan2: foldl' evaluates the accumulator to whnk, foldl doesn't. but both necessarily traverse the complete list
2025-12-19 16:26:31 <yin> s/whnk/whnf
2025-12-19 16:27:31 <milan2> Yeah got it.. but foldl should be able to short-circuit. I just have to write "correct" folding function for it.
2025-12-19 16:28:31 <yin> milan2: how do you figure?
2025-12-19 16:28:34 × lucabtz quits (~lucabtz@user/lucabtz) (Quit: Lost terminal)
2025-12-19 16:29:26 <milan2> I was reading web and I understood it that it can? I might be able to find link.
2025-12-19 16:29:45 <merijn> milan2: Look at my example above :)
2025-12-19 16:29:51 <merijn> > foldl f z [a,b,c]
2025-12-19 16:29:52 <lambdabot> f (f (f z a) b) c
2025-12-19 16:31:10 <milan2> If we look only on c we might be able to short-circuit?
2025-12-19 16:31:33 <milan2> Thus no need for evaluating first argument?
2025-12-19 16:31:40 × chele quits (~chele@user/chele) (Remote host closed the connection)
2025-12-19 16:32:37 <merijn> Right, but how do you do that without traversing the entire list? ;)
2025-12-19 16:33:15 <merijn> So you can short-circuit in skipping some evaluation of `f`, but you *have* to walk the list
2025-12-19 16:33:25 <milan2> I probably can't so this will not work on infinite lists.
2025-12-19 16:33:46 <merijn> What are you actually trying to do?
2025-12-19 16:34:16 <milan2> Advent of Code 2015 day 1 part 2 broke me :(
2025-12-19 16:35:10 <milan2> Like we need definitelly left fold, and we need to stop counting as soon as we count -1.
2025-12-19 16:35:55 <yin> > foldl' const 0 [undefined]
2025-12-19 16:35:57 <lambdabot> 0
2025-12-19 16:36:07 <yin> > foldl' const 0 (repeat ())
2025-12-19 16:36:24 <lambdabot> Terminated
2025-12-19 16:36:45 <yin> ironically, because it wouldn't terminate
2025-12-19 16:37:02 <sprout> use scan
2025-12-19 16:38:36 <yin> fun to see that i can press ctrl-c to halt `foldl const 0 (repeat ())` in ghci but not foldl'
2025-12-19 16:38:46 <sprout> scan will give you a list of numbers, and you can terminate when you hit -1
2025-12-19 16:39:20 <merijn> 2025 you mean? :p
2025-12-19 16:39:31 <yin> sprout: scanr, which is foldr in disguise
2025-12-19 16:39:48 <milan2> sprout: So scan hmmm... or maybe custom self recursive function.
2025-12-19 16:40:14 <merijn> Avoiding spoilers, my implementation relied on mapAccumL
2025-12-19 16:40:17 <merijn> :t mapAccumL
2025-12-19 16:40:18 <lambdabot> Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
2025-12-19 16:40:21 <milan2> merijn: I started from begining.
2025-12-19 16:40:34 <yin> oh i used scanl
2025-12-19 16:40:54 <merijn> milan2: oh, then it's just coicidence your question seems related to this year's day 1 part 2
2025-12-19 16:41:30 <sprout> I just throw an exception when I am lazy
2025-12-19 16:43:46 lambda_gibbon joins (~lambda_gi@208.83.175.39)
2025-12-19 16:45:32 <probie> For day 1, this year's was definitely annoying. I messed up day 1 part 2 on the first go, because I hadn't realised the values over 100 were in the data, since part 1 was all modulo 100
2025-12-19 16:45:54 fp joins (~Thunderbi@2001-14ba-6e24-3000--198.rev.dnainternet.fi)
2025-12-19 16:47:25 <yin> milan2: good on you for starting at the beginning
2025-12-19 16:47:30 <milan2> I am glad I started with older ones.
2025-12-19 16:48:15 <yin> my day 1 this year: https://paste.jrvieira.com/1766162825403
2025-12-19 16:48:19 × lambda_gibbon quits (~lambda_gi@208.83.175.39) (Ping timeout: 264 seconds)
2025-12-19 16:50:19 <milan2> Lovely really few lines of code even with IO and both parts.
2025-12-19 16:51:14 <yin> not the most readable, one can argue
2025-12-19 16:52:20 <merijn> yin: I always go for most readable and most correct: https://github.com/merijn/AdventOfCode/blob/master/Day1.hs
2025-12-19 16:52:37 <merijn> I immediately got sidetracked by work after doing the first day this year >.>
2025-12-19 16:52:46 <yin> merijn: tl;dr
2025-12-19 16:52:51 <yin> :D
2025-12-19 16:53:12 <milan2> :D
2025-12-19 16:54:33 <yin> yes i was happy for having only 12 days to worry about this week but i got to day 8 until work swallowed my free time
2025-12-19 16:54:43 <milan2> yin: Look yin even with type signatures! Not like yours ;)
2025-12-19 16:55:45 <yin> hey, i did sign main
2025-12-19 16:56:01 <milan2> Anyway sprout so scanl should work for 2015 d1 p2?
2025-12-19 16:56:46 <sprout> milan2: it works for me, but that's egel code
2025-12-19 16:57:15 <sprout> I would assume it works in haskell too. and even be faster due to laziness
2025-12-19 16:59:28 <yin> merijn: i'm always sad that Haskell requires so much verbosity in order to guarantee correctness
2025-12-19 16:59:48 <mari-estel> yin: in comparison with?
2025-12-19 17:00:14 <yin> mari-estel: my idealized version of Haskell :)
2025-12-19 17:00:25 <yin> i mean the potential is there
2025-12-19 17:00:54 × omidmash quits (~omidmash@user/omidmash) (Quit: The Lounge - https://thelounge.chat)
2025-12-19 17:01:14 <yin> prelude doesn't even help
2025-12-19 17:02:10 <merijn> yin: I disagree, tbh :p
2025-12-19 17:02:34 <merijn> I find that Haskell (on average) requires *less* verbosity than most other languages to guarantee correctness
2025-12-19 17:02:58 <merijn> It's just easier to not write that stuff in other languages
2025-12-19 17:03:40 × jinsun- quits (jinsun@here.and.ready-to.party) (Changing host)
2025-12-19 17:03:40 jinsun- joins (jinsun@user/jinsun)
2025-12-19 17:03:40 jinsun- is now known as jinsun
2025-12-19 17:07:08 × mari-estel quits (~mari-este@user/mari-estel) (Read error: Connection reset by peer)
2025-12-19 17:07:20 mari-estel joins (~mari-este@user/mari-estel)
2025-12-19 17:09:27 <yin> yes. my point is that Haskell could be much more terse with little effort. it's unrealized potential
2025-12-19 17:10:33 ZLima12 joins (~zlima12@user/meow/ZLima12)
2025-12-19 17:10:39 × ZLima12_ quits (~zlima12@user/meow/ZLima12) (Ping timeout: 260 seconds)
2025-12-19 17:11:53 <yin> as for prelude not helping i'm thinking of partial functions, using Int for everything, etc... the usual complaints
2025-12-19 17:14:07 × fp quits (~Thunderbi@2001-14ba-6e24-3000--198.rev.dnainternet.fi) (Ping timeout: 264 seconds)
2025-12-19 17:17:37 omidmash joins (~omidmash@user/omidmash)
2025-12-19 17:23:48 × Googulator17 quits (~Googulato@2a01-036d-0106-48e4-3c18-a4bd-1bda-7c8b.pool6.digikabel.hu) (Quit: Client closed)
2025-12-19 17:24:05 Googulator17 joins (~Googulato@2a01-036d-0106-48e4-3c18-a4bd-1bda-7c8b.pool6.digikabel.hu)
2025-12-19 17:24:24 × trickard_ quits (~trickard@cpe-81-98-47-163.wireline.com.au) (Read error: Connection reset by peer)
2025-12-19 17:24:37 trickard_ joins (~trickard@cpe-81-98-47-163.wireline.com.au)
2025-12-19 17:25:41 lambda_gibbon joins (~lambda_gi@208.83.175.39)
2025-12-19 17:30:46 × cstml3 quits (~cstml@user/cstml) (Quit: ZNC 1.10.1 - https://znc.in)

All times are in UTC.