Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-24 15:23:46 <bor0> besides naming, I'm curious to see if there's a more elegant way to write these functions
2021-04-24 15:25:11 × dixie quits (~dixie@real.wilbury.sk) (Ping timeout: 240 seconds)
2021-04-24 15:25:27 <ski> it's not at all clear what the intent of `applyX' nor `getX' is
2021-04-24 15:25:54 dixie joins (~dixie@real.wilbury.sk)
2021-04-24 15:26:05 <ski> also, as you've stated them, they're only partially defined (not defined for all inputs). perhaps you'd prefer making them total ?
2021-04-24 15:26:43 <ski> also, one would wonder, whether when you say `[GoLeft:xs]', perhaps you actually meant `(GoLeft:xs)'
2021-04-24 15:26:44 is_null joins (~jpic@pdpc/supporter/professional/is-null)
2021-04-24 15:26:52 <bor0> Ah yeah, I was just trying to capture the idea, they're total otherwise (you helped me construct these the other day :)) Basically, applyX accepts a list of paths (lefts and rights) and specifically applies the function `r` to this term
2021-04-24 15:27:06 × kiweun quits (~kiweun@cpe98524a8cef7c-cm98524a8cef7a.cpe.net.cable.rogers.com) (Ping timeout: 240 seconds)
2021-04-24 15:27:25 <bor0> I can paste the full def, if that would help
2021-04-24 15:27:28 <ski> mm. it's also not clear where `f' comes from
2021-04-24 15:28:09 <ski> perhaps you could state some kind of specification, or intent, about what these two functions are meant for
2021-04-24 15:29:08 <bor0> Here's it: https://paste.tomsmeding.com/047Vypqa
2021-04-24 15:29:13 <ski> (mm, i had a vague memory of `GoLeft' and was wondering whether this was related)
2021-04-24 15:29:52 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds)
2021-04-24 15:30:32 <bor0> So basically I am wondering if there's a better name than `applyArithRule` (I have several rules of type `Arith a -> Arith a`), and I am also curious if there's a more elegant way to write this function. The thing is, I have another function (getArithTerm) which is very close to the original so I feel like I am duplicating things. https://paste.tomsmeding.com/zAfE37rR
2021-04-24 15:31:12 geowiesnot joins (~user@87-89-181-157.abo.bbox.fr)
2021-04-24 15:31:31 <bor0> One is just getting the term from a specific Path, the other one is modifying a term on a specific Path
2021-04-24 15:31:34 × is_null quits (~jpic@pdpc/supporter/professional/is-null) (Ping timeout: 252 seconds)
2021-04-24 15:32:20 is_null joins (~jpic@pdpc/supporter/professional/is-null)
2021-04-24 15:33:06 vicfred joins (~vicfred@unaffiliated/vicfred)
2021-04-24 15:36:34 <ski> hm
2021-04-24 15:37:17 <ski> i'd wonder if you might want to catch failure to apply a rule (e.g. because the indicated position doesn't exist)
2021-04-24 15:37:27 <ski> s/want to/want to be able to/
2021-04-24 15:38:15 <bor0> Hm, yeah, maybe I could use `Either` for that
2021-04-24 15:38:36 <emetrusky> how would i output a table from a list of items that have different data types
2021-04-24 15:38:36 <emetrusky> my data type is this
2021-04-24 15:38:37 <emetrusky> type NorthEast = (Int,Int)
2021-04-24 15:38:37 <emetrusky> data City = City{name ::String,
2021-04-24 15:38:38 <emetrusky>                 northeast :: NorthEast,
2021-04-24 15:38:38 <emetrusky>                 population :: [Int]}
2021-04-24 15:38:39 <emetrusky>                 deriving (Show,Read, Eq)
2021-04-24 15:38:41 <bor0> Lines 16-21 and lines 28-34 feel like duplicating at https://paste.tomsmeding.com/zAfE37rR. But at the same time I don't see an easy way to abstract this
2021-04-24 15:38:43 <ski> regarding the duplication, you might be able to avoid that, by adopting some form of "functional references" (the most popular form of being lenses)
2021-04-24 15:38:53 × geowiesnot quits (~user@87-89-181-157.abo.bbox.fr) (Ping timeout: 246 seconds)
2021-04-24 15:39:14 <bor0> Ah, ok. That goes beyond my current knowledge, but I've heard about lenses. Might worth digging into it
2021-04-24 15:40:10 <ski> emetrusky : what's your list of items ?
2021-04-24 15:40:17 × Flonk quits (~Flonk@ec2-34-221-127-147.us-west-2.compute.amazonaws.com) (Quit: ZNC - http://znc.in)
2021-04-24 15:41:39 <emetrusky> testData :: [City]
2021-04-24 15:41:40 <emetrusky> testData = [City "Amsterdam" (52,5) [1158, 1149, 1140, 1132],
2021-04-24 15:41:40 <ski> emetrusky : also, my guess is that the `NorthEast' naming here isn't that great. presumably the point is to indicate relative or absolute position, or coordinates, and that that may be represented as an amount in the north direction, and an mount in the east direction, is merely an implementation detail, irrelevant to most of the code, no ?
2021-04-24 15:41:40 <emetrusky>             City "Athens" (38,23) [3153, 3153, 3154, 3156],
2021-04-24 15:41:41 <emetrusky>             City "Berlin" (53,13) [3567, 3562, 3557, 3552],
2021-04-24 15:41:41 <emetrusky>             City "Brussels" (51,4) [2096, 2081, 2065, 2050],
2021-04-24 15:41:42 <emetrusky>             City "Bucharest" (44,26) [1794, 1803, 1812, 1821],
2021-04-24 15:41:42 <emetrusky>             City "London" (52,0) [9426, 9304, 9177, 9046],
2021-04-24 15:41:43 <emetrusky>             City "Madrid" (40,4) [6669, 6618, 6559, 6497],
2021-04-24 15:41:43 <emetrusky>             City "Paris" (49,2) [11079, 11017, 10958, 10901],
2021-04-24 15:41:44 <emetrusky>             City "Rome" (42,13) [4278, 4257, 4234, 4210],
2021-04-24 15:41:44 <emetrusky>             City "Sofia" (43,23) [1284, 1281, 1277, 1272],
2021-04-24 15:41:45 <emetrusky>             City "Vienna" (48,16) [1945, 1930, 1915, 1901],
2021-04-24 15:41:45 <emetrusky>             City "Warsaw" (52,21) [1790, 1783, 1776, 1768]]
2021-04-24 15:42:02 <ski> also, please don't paste large amounts of lines into the channel
2021-04-24 15:42:06 <ski> @where paste
2021-04-24 15:42:07 <lambdabot> Help us help you: please paste full code, input and/or output at e.g. https://paste.tomsmeding.com
2021-04-24 15:42:56 <ski> emetrusky : output one line at a time ?
2021-04-24 15:42:58 <emetrusky> ski: the northeast is coordinated
2021-04-24 15:43:42 <ski> perhaps first generate a list of rows of columns, then determine the maximum width of columns in order to properly pad, before outputting, or something like that
2021-04-24 15:44:10 <emetrusky> here is my code so far
2021-04-24 15:44:11 <emetrusky> https://paste.tomsmeding.com/qd5qw6hA
2021-04-24 15:44:22 <ski> (i was figuring they were coordinates of some sort, yes)
2021-04-24 15:44:31 × is_null quits (~jpic@pdpc/supporter/professional/is-null) (Read error: Connection reset by peer)
2021-04-24 15:44:40 <emetrusky> yes they are coordinates as an int
2021-04-24 15:45:04 vulcan01 joins (~Perpetual@c-73-254-191-149.hsd1.wa.comcast.net)
2021-04-24 15:45:10 <ski> so, perhaps you could rename `NorthEast' to `Coord' or `Pos', then ?
2021-04-24 15:45:22 <emetrusky> yep i will do that
2021-04-24 15:45:54 <ski> @type find :: (a -> Bool) -> [a] -> Maybe a
2021-04-24 15:45:56 <lambdabot> (a -> Bool) -> [a] -> Maybe a
2021-04-24 15:45:56 Flonk joins (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com)
2021-04-24 15:46:01 × Tario quits (~Tario@201.192.165.173) (Read error: Connection reset by peer)
2021-04-24 15:46:03 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-24 15:46:14 × frozenErebus quits (~frozenEre@37.231.244.249) (Client Quit)
2021-04-24 15:47:49 <emetrusky> changed northeast to position
2021-04-24 15:47:50 <emetrusky> https://paste.tomsmeding.com/wwDHK2QR
2021-04-24 15:48:11 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-24 15:48:33 × ep1ctetus quits (~epictetus@ip72-194-54-201.sb.sd.cox.net) (Read error: Connection reset by peer)
2021-04-24 15:49:02 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-04-24 15:49:10 <ski> `listToSting' (did you mean `listToString') needs a base case
2021-04-24 15:49:44 <emetrusky> listToString to make the population a string to make it easier to display
2021-04-24 15:49:50 is_null joins (~jpic@pdpc/supporter/professional/is-null)
2021-04-24 15:50:06 × gentauro quits (~gentauro@unaffiliated/gentauro) (Ping timeout: 265 seconds)
2021-04-24 15:50:06 <ski> i see
2021-04-24 15:50:17 × Flonk quits (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com) (Quit: The Lounge - https://thelounge.chat)
2021-04-24 15:50:38 Flonk joins (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com)
2021-04-24 15:50:58 <ski> will all the population lists have the same length, within a single list of test data ?
2021-04-24 15:51:04 Tario joins (~Tario@201.192.165.173)
2021-04-24 15:51:26 <emetrusky> yes all populations will have the same length of test data
2021-04-24 15:51:28 <ski> will all population lists always have length four ?
2021-04-24 15:51:42 <emetrusky> no
2021-04-24 15:52:06 <emetrusky> eventually i will make a function that will allow me to add elements to the list
2021-04-24 15:52:08 × Mrbuck quits (~Mrbuck@gateway/tor-sasl/mrbuck) (Remote host closed the connection)
2021-04-24 15:52:23 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-04-24 15:52:35 <ski> findCity name cities = head (filter (\(City n _ _ ) -> n == name) cities)
2021-04-24 15:52:55 <ski> findCity name0 cities = head (filter (\city -> name city == name0) cities)
2021-04-24 15:54:15 <emetrusky> i dont quite understand why you have removed the () -> n?
2021-04-24 15:54:31 <emetrusky> if you could explain that would be helpful?
2021-04-24 15:55:00 <ski> record notation, `data City = City {name :: String,...}' already gives you `name' as a field selector to extract the name
2021-04-24 15:55:20 × stree quits (~stree@68.36.8.116) (Ping timeout: 246 seconds)
2021-04-24 15:55:44 <ski> so, by avoiding the shadowing of that (by renaming the parameter from `name' to `name0'), you can use that to access the name of the current city, rather than having to use pattern-matching there
2021-04-24 15:56:20 <emetrusky> oh ok thanks

All times are in UTC.