Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,203 events total
2021-08-21 17:12:35 <Guest2172> Could somebody help me regarding my haskell homework?
2021-08-21 17:13:13 <sm> if you want positioned input fields, it's brick or make your own with vty or ansi-terminal I think
2021-08-21 17:14:01 <sm> @where paste, Guest2172
2021-08-21 17:14:01 <lambdabot> I know nothing about paste,.
2021-08-21 17:14:17 <sm> @where paste
2021-08-21 17:14:17 <lambdabot> Help us help you: please paste full code, input and/or output at e.g. https://paste.tomsmeding.com
2021-08-21 17:14:27 <Guest2172> Ah. Gimme a sec
2021-08-21 17:14:55 son0p joins (~ff@181.136.122.143)
2021-08-21 17:15:09 <Athas> sm: that looks interesting!
2021-08-21 17:15:19 <Athas> I have no opinion on positioning.
2021-08-21 17:15:34 <Guest2172> https://paste.tomsmeding.com/ctfNt47T this good?
2021-08-21 17:15:42 <sm> i use wizards for hledger add, it's great
2021-08-21 17:16:13 <sm> that's good Guest2172, what are you stuck on ?
2021-08-21 17:16:55 <Guest2172> Basically where to start. My mind can't think Haskell at all
2021-08-21 17:17:17 <sm> is there a simpler problem you could tackle first ?
2021-08-21 17:17:40 <Guest2172> There are a few, yea. Was just thinking that one would end up being easy
2021-08-21 17:18:01 <Guest2172> There's a multi-part one that I started, give me a second
2021-08-21 17:18:25 <sm> or maybe the first couple at project euler or exercism.io would get you warmed up
2021-08-21 17:19:05 <Guest2172> I am warmed up a bit, have been trying to work through these the entire day
2021-08-21 17:19:12 × mestre quits (~mestre@191.177.175.57) (Quit: leaving)
2021-08-21 17:19:28 mestre joins (~mestre@191.177.175.57)
2021-08-21 17:19:29 <Guest2172> https://paste.tomsmeding.com/e8D0Jsqv
2021-08-21 17:20:43 <Guest2172> I don't really get how I'm supposed to get StockL out of the definition at the top
2021-08-21 17:22:07 jtomas joins (~jtomas@233.red-83-34-2.dynamicip.rima-tde.net)
2021-08-21 17:22:27 <__monty__> Do you understand why your solution for countF works?
2021-08-21 17:23:44 <Guest2172> Partially.
2021-08-21 17:24:23 <sm> good answer :)
2021-08-21 17:24:45 <maerwald> can someone explain to me how Data.Char.isLower is implemented? It ends up like an boscure ffi call it seems to https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/base/cbits/WCsubst.c which I don't understand
2021-08-21 17:24:49 <Guest2172> I am assuming that the Item datatype is acting like a lookup table when Single_Apple is mentioned
2021-08-21 17:25:04 <sm> it looks like you know how to get the list of items, now you need a way to look up one item in that list
2021-08-21 17:26:22 <sm> hint: there's a function in Prelude called lookup
2021-08-21 17:26:40 × jtomas quits (~jtomas@233.red-83-34-2.dynamicip.rima-tde.net) (Remote host closed the connection)
2021-08-21 17:28:18 <monochrom> or you could write your own recursion. it's a good exercise anyway, even if you throw it away afterwards
2021-08-21 17:28:43 <monochrom> unless you have no idea how to work with a list
2021-08-21 17:28:55 <monochrom> in which case more needs for more fingering exercises
2021-08-21 17:29:33 <Guest2172> I do know how to work a list, dw
2021-08-21 17:29:42 jakalx parts (~jakalx@base.jakalx.net) (Error from remote client)
2021-08-21 17:29:56 <monochrom> It takes zero understanding to say "StockL is some kind of database". Every random person on the street knows that much.
2021-08-21 17:30:39 <Guest2172> Yea, I'm just dumb when it comes to Haskell
2021-08-21 17:31:02 <Guest2172> Give me Python, c or c++ and I'll do just fine. Give me Haskell and I literally can't think
2021-08-21 17:31:23 <sm> it takes time to rewire the brain for it
2021-08-21 17:31:35 <sm> soon it'll be easy
2021-08-21 17:32:18 <Clint> maerwald: looks like it's just checking an autogenerated lookup table for a flag
2021-08-21 17:32:35 <maerwald> yeah, I'm screwed
2021-08-21 17:32:37 <sm> Have you read a lot of (simple) haskell code ? this can help a lot I think
2021-08-21 17:34:03 <__monty__> Guest2172: Could you say in a sentence or two how countF works? I think it'll help with a misunderstanding in your commented out countL.
2021-08-21 17:34:34 pbrisbin joins (~patrick@174-081-116-011.res.spectrum.com)
2021-08-21 17:35:00 pavonia joins (~user@user/siracusa)
2021-08-21 17:37:47 shriekingnoise joins (~shrieking@186.137.144.80)
2021-08-21 17:38:02 mastarija joins (~mastarija@78-3-210-70.adsl.net.t-com.hr)
2021-08-21 17:38:49 <Guest2172> countF takes in a variable of type StockF, and parses that to getStockF, which acts as a lookup for those items.
2021-08-21 17:41:14 <Guest2172> Is that correct?
2021-08-21 17:41:47 <Guest2172> __monty__
2021-08-21 17:42:52 <pavonia> maerwald: What are you trying to do?
2021-08-21 17:43:18 <maerwald> pavonia: toUpper for Word16, similar to the word8 package
2021-08-21 17:43:33 × neo quits (~neo3@cpe-292712.ip.primehome.com) (Quit: Leaving)
2021-08-21 17:43:53 neo joins (~neo3@cpe-292712.ip.primehome.com)
2021-08-21 17:46:09 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-21 17:50:00 × wallymathieu quits (~wallymath@81-234-151-21-no94.tbcn.telia.com) (Quit: Textual IRC Client: www.textualapp.com)
2021-08-21 17:50:34 <tomsmeding> maerwald: https://hackage.haskell.org/package/base-4.15.0.0/docs/src/GHC-Unicode.html says that the implementation uses libunicode if that's available
2021-08-21 17:50:46 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Ping timeout: 250 seconds)
2021-08-21 17:51:29 <dsal> Guest2172: I don't think I'd phrase it that way.
2021-08-21 17:51:36 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-21 17:51:44 <Guest2172> I just can't think haskell
2021-08-21 17:52:12 <__monty__> Guest2172: Not quite. You're saying `getStockF` is the function that takes an item and returns a count?
2021-08-21 17:52:25 <__monty__> What is `x`?
2021-08-21 17:53:02 Erutuon joins (~Erutuon@user/erutuon)
2021-08-21 17:53:19 <Guest2172> `x` is StockF f
2021-08-21 17:54:06 <__monty__> Yes, and StockF f is a record, with one field called `getStockF`.
2021-08-21 17:54:34 <__monty__> This field is also a function that extracts the value of the field from such a record.
2021-08-21 17:55:05 <tomsmeding> maerwald: oh but a comment later on claims that the WCsubst.c functions are used unconditionally?
2021-08-21 17:55:52 <__monty__> So `getStockF x` is just the value of the similarly named field.
2021-08-21 17:56:27 <maerwald> yeah, I think there's no way I can have toLower on Word16 reasonably without converting to Char
2021-08-21 17:56:43 <maerwald> for Word8 it's straight forward
2021-08-21 17:56:51 <Guest2172> So if I were to write them down exactly the same, getStockL x would give me the list, right?
2021-08-21 17:56:59 <__monty__> Guest2172: It's clearer if you make it less pointfree. `countF x i = (getStockF x) i`, you see? So what's wrong with your proposed countL?
2021-08-21 17:57:02 <__monty__> Yes, exactly.
2021-08-21 17:57:16 <__monty__> So passing a list to `getStockL` wouldn't work.
2021-08-21 17:57:40 <__monty__> Now that you know how to get the list you should be able to implement countL.
2021-08-21 17:58:25 severen joins (~severen@202.36.179.72)
2021-08-21 17:58:46 <pavonia> maerwald: You could also filter the Unicode database files yourself and create a static mapping. The format is quite simple
2021-08-21 17:59:26 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Ping timeout: 250 seconds)
2021-08-21 18:00:41 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-21 18:00:58 <Guest2172> I am confused how I should apply both getStockL and lookup though. getStockL x gives me the list, and somehow I'm supposed to use lookup to get the second element in that list
2021-08-21 18:01:14 × bitmapper quits (uid464869@id-464869.tooting.irccloud.com) (Quit: Connection closed for inactivity)
2021-08-21 18:01:28 jtomas joins (~jtomas@233.red-83-34-2.dynamicip.rima-tde.net)
2021-08-21 18:01:56 jakalx joins (~jakalx@base.jakalx.net)
2021-08-21 18:02:52 <maerwald> my property tests say that `toUpper = charToWord16 . C.toUpper . word16ToChar` is safe, because Data.Char.toUpper never goes beyond Word16 maxBound :p
2021-08-21 18:02:56 <maerwald> that's luck
2021-08-21 18:04:16 <tomsmeding> maerwald: what it ends up doing is a binary search in the allchars[] list starting on line 303; the entries are {starting codepoint, number of points in block, rule of this block}. The rules are defined directly above the allchars table, where the first item in the {} is the category, which is a bitwise OR of some of the GENCAT_?? defines, which are all distinct, single bits
2021-08-21 18:04:37 <maerwald> yeah, pretty sure I don't wanna understand it :p
2021-08-21 18:04:45 <tomsmeding> and it tests if the category has the GENCAT_LL bit set :)
2021-08-21 18:05:04 × nate1 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 250 seconds)
2021-08-21 18:06:05 <tomsmeding> it divides up the codepoints 0 to 65535 in 2719 blocks of the same category
2021-08-21 18:06:40 <tomsmeding> this would be very easy to convert to whatever format you want it in, but at that point you can also generate it from the official UnicodeData.txt file :p
2021-08-21 18:06:45 <__monty__> Guest2172: You can just apply a function to the value `f (getStockL x)`.
2021-08-21 18:06:57 × pbrisbin quits (~patrick@174-081-116-011.res.spectrum.com) (Ping timeout: 248 seconds)
2021-08-21 18:07:19 <__monty__> Guest2172: I'd try implementing the recursion though, it's good practice.
2021-08-21 18:07:48 <tomsmeding> maerwald: pretty sure that toUpper-closedness is not luck; 0000-FFFF is the so-called Basic Multilingual Plane and is a closed set of stuff
2021-08-21 18:07:57 <maerwald> oh

All times are in UTC.