Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-07 05:21:31 <swarmcollective> monochrom: How long have you worked with Haskell?
2021-03-07 05:21:49 <monochrom> Pretty long? I ran into it circa year 2000.
2021-03-07 05:22:08 <swarmcollective> Oh, lucky you!
2021-03-07 05:22:13 <monochrom> But my thoughts I'm describing now were from my BASIC and Pascal days.
2021-03-07 05:22:52 <Cale> Imagine what the web would look like today if Javascript was something that was more of a reasonable target language for compilers, like LLVM.
2021-03-07 05:22:52 <heck-to-the-gnom> swarmcollective: Then no one would hate the modern web as us technologically informed people do
2021-03-07 05:22:59 <swarmcollective> I understand. I did not have that revelation, regarding mutable variables and recursion.
2021-03-07 05:23:12 Saukk joins (~Saukk@83-148-239-3.dynamic.lounea.fi)
2021-03-07 05:23:46 <monochrom> CS courses I took presented both a loop algorithm and a recursive algorithm, both in Pascal, for linked list operations. I immediately felt in love with the recursive ones.
2021-03-07 05:25:11 <heck-to-the-gnom> Recursion is definitely really cool. My mind was blown when I first came across it. Apparently there's some malware going around that is 100% recursive in nature, security researchers had a really hard time understanding it.
2021-03-07 05:25:13 <MarcelineVQ> I still get tickled that you can, in a sense, make use of a value before it exists with recursion.
2021-03-07 05:25:49 <monochrom> If you look at everything in the world recursively, suddenly "how is it possible to compute anything without state" sounds silly.
2021-03-07 05:26:16 <swarmcollective> Only formal programming training for me was BASIC and RPG II in high-school. I believe I would have really enjoyed college / university level programming courses.
2021-03-07 05:26:20 <MarcelineVQ> span being my go to example for that https://hackage.haskell.org/package/base-4.14.1.0/docs/src/GHC.List.html#span
2021-03-07 05:26:39 × ech_ quits (~user@gateway/tor-sasl/ech) (Ping timeout: 268 seconds)
2021-03-07 05:26:46 <dolio> Web stuff would probably still be pretty bad even if JS were good.
2021-03-07 05:27:12 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-03-07 05:27:45 <monochrom> To be sure, if you don't have mutable arrays, you do lose a few important efficient algorithms. But no one here is saying you never need them. I for one am just saying mutable variables are overrated for the rest.
2021-03-07 05:28:03 <monochrom> And it's only because BASIC makes recursion useless.
2021-03-07 05:28:09 <d34df00d> swarmcollective: no worries, thanks for taking a look!
2021-03-07 05:28:39 <heck-to-the-gnom> dolio: Likely, but JS is the biggest issue. Meaning that things like gopher or gemeni thrive because they don't do any of the BS thrills that normies are used to
2021-03-07 05:28:59 <heck-to-the-gnom> Gemini*
2021-03-07 05:29:31 <swarmcollective> Ahhh, `span` is like `partition` except for "front, back". Nice.
2021-03-07 05:30:08 <heck-to-the-gnom> @hoogle [a] -> a -> a
2021-03-07 05:30:10 <lambdabot> Util seqList :: [a] -> b -> b
2021-03-07 05:30:10 <lambdabot> MathObj.Permutation.CycleList cycleAction :: Eq i => [i] -> i -> i
2021-03-07 05:30:10 <lambdabot> MathObj.PowerSeries.Core evaluate :: C a => [a] -> a -> a
2021-03-07 05:30:19 <Cale> span and break are more closely related than span and partition
2021-03-07 05:30:49 <Cale> partition splits the list into all the elements that satisfy the predicate and all those which don't
2021-03-07 05:30:55 <swarmcollective> True, good point Cale
2021-03-07 05:31:23 <Cale> span splits the list into the longest initial segment which satisfies the predicate, and the rest
2021-03-07 05:31:33 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 246 seconds)
2021-03-07 05:31:39 <heck-to-the-gnom> Hmm, is there a `:`, but instead of a prepending, appending? e.g `[a] ^: b` == `[a,b]`
2021-03-07 05:31:57 <swarmcollective> I suspect that I've been abusing partition where I should be using a map.
2021-03-07 05:32:43 <monochrom> span/break are related to takeWhile and dropWhile. filter is related to partition.
2021-03-07 05:32:48 <Cale> heck-to-the-gnom: Nope, you can use xs ++ [x], but it's a fundamentally expensive operation. If you have to do it a lot, then it might be more correct to store your list in the opposite order, or use a different sort of data structure.
2021-03-07 05:32:54 <swarmcollective> heck-to-the-gnom: snoc (and it's cousin cons), but it is in "extra", not prelude or base.
2021-03-07 05:34:40 × justsomeguy quits (~justsomeg@unaffiliated/--/x-3805311) (Quit: WeeChat 3.0.1)
2021-03-07 05:35:56 <heck-to-the-gnom> No, I was just wondering if I could simplify my self-defined (because I don't feel like installing Extra right now) cons & snoc
2021-03-07 05:36:14 <Cale> The reason it's expensive is that by contrast with (x:xs) which allocates a small structure that has pointers to x and xs in it, it has to reconstruct the entire list -- it can't just point at something which already exists in memory since the result in general won't have any tail in common with the original list.
2021-03-07 05:36:24 <Cale> (except the [] at the end of course)
2021-03-07 05:37:04 <heck-to-the-gnom> Curious: why ever use a list, when arrays are more performant?
2021-03-07 05:37:19 sheepfleece joins (~sheep@46.53.248.142)
2021-03-07 05:37:57 <Cale> They're not
2021-03-07 05:38:25 <Cale> If you want to add an element to an array anywhere, you end up allocating an entirely new array and copying everything into it
2021-03-07 05:39:26 <heck-to-the-gnom> Fair point
2021-03-07 05:39:42 <Cale> There's also a sense in which a lazy list is essentially a loop which hasn't happened yet
2021-03-07 05:40:08 × sheepfleece quits (~sheep@46.53.248.142) (Client Quit)
2021-03-07 05:40:09 <Cale> A loop might have no iterations (because its precondition isn't met, for example), or it might consist of an iteration followed by another loop
2021-03-07 05:40:30 <Cale> A list might have no elements (because it's the empty list), or it might consist of a single element followed by another list
2021-03-07 05:40:54 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 260 seconds)
2021-03-07 05:40:56 <Cale> Putting stuff in a list is a way of expressing "I want to iterate over these things in this order"
2021-03-07 05:41:48 <Cale> In a lazy setting, that connection is more satisfying, since you might only allocate one element of the list at a time, and it may be infinitely long
2021-03-07 05:42:37 × slack1256 quits (~slack1256@dvc-186-186-101-190.movil.vtr.net) (Ping timeout: 276 seconds)
2021-03-07 05:42:37 <swarmcollective> Cale, is that, at least in part, why String is so popular when Text and ByteString, if I understand correctly, are more memory efficient? Text and ByteString using arrays under the hood?
2021-03-07 05:43:02 <monochrom> String is more popular just because it's older.
2021-03-07 05:43:26 <Cale> Yeah, String has just been around longer... iterating over characters one by one is not all that great a lot of the time.
2021-03-07 05:43:44 <heck-to-the-gnom> OK, third random question within the last 10 minutes:
2021-03-07 05:44:20 <heck-to-the-gnom> Am I using a list comprehension guard correctly? `[x | x <- u, ifFloat'' x]`, where `ifFloat''` takes one argument
2021-03-07 05:44:22 <swarmcollective> heck-to-the-gnom: First two are free, the third costs 100 push-ups.
2021-03-07 05:44:33 <heck-to-the-gnom> ;)
2021-03-07 05:44:59 <Cale> heck-to-the-gnom: There's nothing obviously wrong with that. u should be a list of potential arguments to ifFloat'' and the result of ifFloat'' should be Bool
2021-03-07 05:45:13 × elliott_ quits (~elliott_@pool-108-51-101-42.washdc.fios.verizon.net) (Read error: Connection reset by peer)
2021-03-07 05:46:26 <heck-to-the-gnom> Ah, I see, I was returning bool, but since I hadn't explicitly declared it the compiler got confused due to my particular usage
2021-03-07 05:47:10 <heck-to-the-gnom> One more reason for me to start typing my things, before GHC changes something under the hood and all of a sudden all my programs don't compile
2021-03-07 05:49:20 elliott_ joins (~elliott_@pool-108-51-101-42.washdc.fios.verizon.net)
2021-03-07 05:49:46 <swarmcollective> Is there a constraint similar to Num or Integral that can be used for "String-like" which will allow a function to take String, Text, or ByteString given the implementation is compatible? My assumption is, No, but if there is it might be handy.
2021-03-07 05:49:56 <Cale> heck-to-the-gnom: Type inference is usually pretty consistent, but you'll get better error messages if you give types to things.
2021-03-07 05:50:34 <Cale> swarmcollective: There could be, but it's hard to agree on exactly what operations it should contain
2021-03-07 05:51:15 swarmcollective nods
2021-03-07 05:51:34 <Cale> If all you want is concatenation and an empty element, you could use Monoid.
2021-03-07 05:52:55 <heck-to-the-gnom> Couldn't match expected type `a` with actual type `Maybe k0` `a` is a rigid type variable bound by the type signature for: ifFloat'' :: forall a. a -> Bool
2021-03-07 05:52:55 <heck-to-the-gnom> where I'm using `let blah = blah in case blah of Just x | blah x -> True; _ -> False`
2021-03-07 05:53:07 <heck-to-the-gnom> What am I doing wrong there?
2021-03-07 05:53:21 <dmwit> swarmcollective: You might like the mono-traversable package.
2021-03-07 05:53:25 drbean joins (~drbean@TC210-63-209-198.static.apol.com.tw)
2021-03-07 05:53:31 <swarmcollective> It seems, naively, that cons, snoc, (++ & append & concat), null or pattern Empty would all be useful.
2021-03-07 05:53:39 <dmwit> It provides MonoTraversable instances for String, Text, and ByteString.
2021-03-07 05:53:46 <heck-to-the-gnom> Should I do `Maybe False`?
2021-03-07 05:53:59 <swarmcollective> Hmmm. Thanks dmwit ! I'll have a look.
2021-03-07 05:54:14 <dmwit> heck-to-the-gnom: insufficient data for meaningful answer
2021-03-07 05:54:27 <heck-to-the-gnom> hm... OK, paste comin' up
2021-03-07 05:54:36 <dmwit> heck-to-the-gnom: Make a minimal reproducible example and put it up on a pastebin somewhere (e.g. gist.github.com).
2021-03-07 05:54:56 <swarmcollective> heck-to-the-gnom: definitely use "false-ish" (just kidding)
2021-03-07 05:56:16 myShoggoth joins (~myShoggot@75.164.81.55)
2021-03-07 05:59:18 <Cale> heck-to-the-gnom: Well, the first sketchy thing is that blah = blah will be an infinite loop
2021-03-07 05:59:28 <heck-to-the-gnom> lol
2021-03-07 05:59:33 <heck-to-the-gnom> dmwit: https://p.bsd-unix.net/view/fecb5f33
2021-03-07 05:59:50 <Cale> heck-to-the-gnom: and then you're pattern matching on blah as something of type Maybe t (for some t we can't discern)
2021-03-07 05:59:58 <Cale> but you're also using blah as a function
2021-03-07 06:00:05 <Cale> applying it to a value of type t
2021-03-07 06:00:16 <dmwit> Well, your `ifFloat''` *definitely* doesn't have type `a -> Bool`.
2021-03-07 06:00:17 <Cale> blah can't be both a function and a value of type Maybe t at the same time
2021-03-07 06:00:28 <heck-to-the-gnom> it doesn't!?
2021-03-07 06:00:59 <Cale> Yeah, wind is definitely a Maybe something
2021-03-07 06:01:06 <dmwit> The type `a -> Bool` says that I, the caller, may choose any type I like, say, Dmwit'sRadThingThatHeckToTheGnomeNeverHeardOf, and you'll give me back a Bool from one of those.
2021-03-07 06:01:37 <dmwit> Next up: `gets windowset` is almost certainly an action in the `X` monad, so `M.member w` ain't gonna work.
2021-03-07 06:01:50 <dmwit> Sorry, I mean `W.floating ws` ain't gonna work.
2021-03-07 06:02:22 <dmwit> I think you're going to have to run `gets windowset` in `oi` first, and pass the result in as an argument to `ifFloat''`.
2021-03-07 06:02:46 jakalx parts (~jakalx@base.jakalx.net) ("Error from remote client")

All times are in UTC.