Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,998 events total
2021-08-06 05:53:41 <jle`> > map read . filter isDigit . splitOn "," $ "[(233,173,20), (200, 10, 155)]" :: [Word8]
2021-08-06 05:53:43 <lambdabot> error:
2021-08-06 05:53:43 <lambdabot> • Couldn't match type ‘Char’ with ‘[Char]’
2021-08-06 05:53:43 <lambdabot> Expected type: [Char] -> [String]
2021-08-06 05:53:59 <jle`> > map (read . filter isDigit) . splitOn "," $ "[(233,173,20), (200, 10, 155)]" :: [Word8]
2021-08-06 05:54:01 <lambdabot> [233,173,20,200,10,155]
2021-08-06 05:54:04 <Cajun> i already have a function `toImage :: Array U DIM2 RGB8 -> Image PixelRGB8` to convert the repa array to a juicepixels image (i could also find something from juicepixels-repa)
2021-08-06 05:54:35 <endlesseditions> random question thats probably been asked 1 billion times before,,,, but, do you all think haskell is a good lang as an introduction to FP? I mostly use Go and Typescript for microsystem development. Really want to get more into FP but not sure what lang i should mess around with first.
2021-08-06 05:54:46 <Axman6> just go straight to Pixel8, seriously, you don't have the RAM not to
2021-08-06 05:55:18 <Cajun> straight to pixel8 but how would i get a list of pixel8 into an image?
2021-08-06 05:55:32 <jle`> endlesseditions: i'd say just jump straight into fp with haskell :) i got a small taste with ruby but jumping from ruby to haskell worked well for me personally
2021-08-06 05:55:39 <Axman6> endlesseditions: if you actually want to learn FP, there's basicaslly no better language, because you don't have the choice to dumb things like use mutation or arbitrary effects in the middle of seemingly pure functions
2021-08-06 05:55:47 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-08-06 05:57:18 <endlesseditions> cool yeah i was seeing some similar stuff to what you said Axman, regarding other langs that are more multiparidigm and can be a bit more lax in terms of what style of programming you do
2021-08-06 05:57:23 <Axman6> you could quite easily use generateFoldImage, where acc is actually the list of pixels, assuming that it works in the same order as your image
2021-08-06 05:57:50 <jle`> Cajun: a juicy pixels image is essentially internally a Data.Vector of pixels
2021-08-06 05:58:01 <jle`> oh, not even of pixels. of pixel components
2021-08-06 05:58:14 <Axman6> endlesseditions: people get caught up in wanting features they had in other languages because that's what they're used to. It's a trap (as someone who's been writing Scala recently, I can recommend you never, ever, touch it, just don't)
2021-08-06 05:58:15 <jle`> https://hackage.haskell.org/package/JuicyPixels-3.3.5/docs/Codec-Picture-Types.html#t:Image
2021-08-06 05:58:27 <Cajun> hold up am i converting to a list of Pixel8 or a list of PixelRGB8?
2021-08-06 05:58:32 <jle`> Cajun: so you can literally just throw in a vecotor of Word8's
2021-08-06 05:58:42 <endlesseditions> oh man i mean scala looked interesting and all but i kinda want to stay away from jvm to be honest aha
2021-08-06 05:58:56 <jle`> `Image w h (Vector.fromList myListOfWord8s)`
2021-08-06 05:59:05 <endlesseditions> one thing i really like about go is its ability to compile down into simple binary (even if it is a bit bloated)
2021-08-06 05:59:11 anandprabhu_ joins (~anandprab@86.106.121.228)
2021-08-06 05:59:25 <Axman6> generateFoldImage (\(p:ps) _x _y (ps,p)) pixels width height should work
2021-08-06 05:59:28 <jle`> Cajun: of type `Image Pixel8`
2021-08-06 05:59:56 <Axman6> endlesseditions: Haskell is also a compiled language, which usually doeasn't link to much
2021-08-06 06:00:00 <Cajun> that would wind up being greyscale, then im turning an rgb image greyscale and would mess it up entirely
2021-08-06 06:00:06 <endlesseditions> is the Learn You book still the top rec for hoping straight in?
2021-08-06 06:00:20 <Cajun> as each RGB channel would turn into their own monochrome pixels
2021-08-06 06:00:39 <lechner> Hi, I would like to mirror Hackage locally to find prerequisites that are not declared correctly. Unfortunately that is what I may be encountering when trying to build the mirroring tool hackage-mirror. What's the fix, please? Thanks! https://paste.debian.net/1206740/
2021-08-06 06:00:39 <Cajun> they need to stay as 3-tuples then into PixelRGB8
2021-08-06 06:00:44 <jle`> Cajun: no, it's an internal represetation (if you're talking about my method)
2021-08-06 06:00:51 <endlesseditions> and do people ever make CLI's or TUI's in haskell? those are some things im definitely interested as i've mostly just been making cli's lately
2021-08-06 06:01:03 <jle`> Cajun: internally it's stored as a contiguous vector of Word8's. but when you process it as an image, it automatically chunks them up into 3's
2021-08-06 06:01:19 <Axman6> Cajun: why do you say that? o.O
2021-08-06 06:01:27 <jle`> so i guess my method is a bit low-level, heh
2021-08-06 06:01:33 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Quit: leaving)
2021-08-06 06:01:39 <Cajun> ahhh i see. so am i manually constructing an image or something? i still dont get how im making an `Image Pixel8` from a list of word8s
2021-08-06 06:01:47 × anandprabhu quits (~anandprab@94.202.243.198) (Ping timeout: 258 seconds)
2021-08-06 06:01:47 × cheater quits (~Username@user/cheater) (Ping timeout: 258 seconds)
2021-08-06 06:01:49 <jle`> the JuicyPixels library provides an abstraction to work over the raw contiguous bytes as if it were a color image
2021-08-06 06:02:01 <Axman6> Ignore jle` and listen to me :P
2021-08-06 06:02:19 <lechner> I tried to use hvr's hackage-mirror-tool instead but did not fare much better https://paste.debian.net/1206742/ https://github.com/haskell-hvr/hackage-mirror-tool https://groups.google.com/g/stackage/c/Y7NU6qVElZs?pli=1
2021-08-06 06:02:20 <Axman6> (This is usually very bad advice, but I know what I'm talking about here XD)
2021-08-06 06:02:46 cheater joins (~Username@user/cheater)
2021-08-06 06:03:49 <Cajun> now im really confused lol, i now have no idea how im getting from this string to this list of word 8s (im doing this: `map (read . filter isDigit) . splitOn "," $ "[(233,173,20), (200, 10, 155)]" :: [Word8]` right?) then i need that to be a vector and use some function to shove that into an `Image`?
2021-08-06 06:03:54 <jle`> yeah, we are giving sort of contradictory method, so just having one channel of communication is probably better :p
2021-08-06 06:03:58 <Axman6> If you do what I'm saying, you will use the minimum memory needed to allocate the image and read data lazily from disk
2021-08-06 06:04:20 <Axman6> Cajun: that's why you should do what I said instead
2021-08-06 06:04:40 <Axman6> lechner: #haskell-infrastructure might be a better place to ask
2021-08-06 06:04:45 <Cajun> well now i have no idea what that was
2021-08-06 06:05:22 <lechner> Axman6: thanks!
2021-08-06 06:06:23 <Axman6> you code will literally be: generateFoldImage (\(p:ps) _x _y (ps,p)) (map (toPixel . read) . splitOn "," . init . drop 1 $ rawList) width height, assuming you know the dimensions of the image
2021-08-06 06:06:56 <Cajun> i dont know the dimensions of the image, but i guess i just can guess and check. is there any harm if the dimensions are too small/big than the original?
2021-08-06 06:07:06 <Cajun> like, there are too many pixels than are in those dimensions
2021-08-06 06:07:09 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 258 seconds)
2021-08-06 06:07:09 × jespada quits (~jespada@90.254.247.46) (Ping timeout: 258 seconds)
2021-08-06 06:08:20 <Axman6> if they're too small, that'll be fine. if they're too big, then that "(\(p:ps)" will fail and you'll get an exception
2021-08-06 06:09:03 jespada joins (~jespada@90.254.247.46)
2021-08-06 06:10:16 <Axman6> you could put in a case statement in there which checks if the list's empty, and outputs Pixel8 0 0 0
2021-08-06 06:11:51 <Cajun> i would rather get an exception yelling at me than false hopes raysL
2021-08-06 06:12:01 <Cajun> oh yeah no emotes lol
2021-08-06 06:12:08 × zmt00 quits (~zmt00@user/zmt00) (Ping timeout: 258 seconds)
2021-08-06 06:12:45 <Cajun> so `generateFoldImage` gives type `([Pixel], Image Pixel)` which is great, so what do i do with that `Image Pixel` ?
2021-08-06 06:13:38 <Axman6> whatever you want?
2021-08-06 06:13:41 <Axman6> save it to disk?
2021-08-06 06:13:51 <Cajun> alright, ima see if this works, thanks!
2021-08-06 06:14:21 <Axman6> writePng looks like a good place to start
2021-08-06 06:15:48 × willbush quits (~user@47.183.200.14) (Remote host closed the connection)
2021-08-06 06:16:07 <Cajun> problem being, you defined `data Pixel` but that means i need an instance of PngSavable for it
2021-08-06 06:17:42 <Axman6> like I said a few times, use Pixel8 from JuicyPixels
2021-08-06 06:18:21 slavaqq joins (~slavaqq@sdmail.sdserver.cz)
2021-08-06 06:22:12 × curiousgay quits (~curiousga@77-120-186-48.kha.volia.net) (Ping timeout: 245 seconds)
2021-08-06 06:22:15 <Cajun> now im really confused. `toPixel` doesnt exist for Pixel8, i dont want to use the custom defined thing because it doesnt play well with juicypixels, and that code you gave runs into both of those issues
2021-08-06 06:22:31 <Cajun> also, the splitOn makes a mess of the strings
2021-08-06 06:22:34 <Axman6> write it
2021-08-06 06:22:49 <Cajun> i tried and im quite confused how, considering Pixel8 is a type synonym for word8
2021-08-06 06:23:15 × Erutuon quits (~Erutuon@user/erutuon) (Ping timeout: 258 seconds)
2021-08-06 06:23:19 <Axman6> noit's not, it's identical to what I defined before: https://hackage.haskell.org/package/JuicyPixels-3.3.5/docs/Codec-Picture.html#t:PixelRGB8
2021-08-06 06:23:26 <Axman6> uh, ignore that
2021-08-06 06:23:31 <Cajun> that pixelrgb8 not pixel8
2021-08-06 06:23:55 <Axman6> right, you have Word8's, just stick them into the PixelRGB8 constructor
2021-08-06 06:24:00 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-08-06 06:24:11 <Cajun> alright this makes more sense. i was seriously confused when you were saying pixel8 instead of pixelrgb8
2021-08-06 06:24:12 fendor joins (~fendor@178.115.49.9.wireless.dyn.drei.com)
2021-08-06 06:24:14 <Cajun> it compiles now
2021-08-06 06:24:36 <Axman6> yeah sorry, I forgot those had different names
2021-08-06 06:25:26 Lord_of_Life_ joins (~Lord@user/lord-of-life/x-2819915)
2021-08-06 06:25:46 × xff0x_ quits (~xff0x@2001:1a81:52cf:a900:d9f9:1622:609d:b2ef) (Ping timeout: 240 seconds)
2021-08-06 06:25:52 × Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 250 seconds)
2021-08-06 06:26:40 Lord_of_Life_ is now known as Lord_of_Life
2021-08-06 06:26:44 <Cajun> so yeah issue with the parsing. the `splitOn` doesnt play well with list-like strings like jle` showed earlier
2021-08-06 06:26:45 <Cajun> > splitOn "," . drop 1 . init $ "[(233,173,20), (200, 10, 155)]"
2021-08-06 06:26:46 <lambdabot> ["(233","173","20)"," (200"," 10"," 155)"]
2021-08-06 06:27:36 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Client Quit)
2021-08-06 06:27:43 xff0x_ joins (~xff0x@2001:1a81:52e3:2500:9c72:9058:eb7a:ca08)
2021-08-06 06:27:58 <Axman6> oh, that's a great point...
2021-08-06 06:28:19 <Axman6> I forgot that tuples also have ,'s XD

All times are in UTC.