Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-02-27 10:50:00 emmanuel_erc joins (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com)
2021-02-27 10:52:14 <tomsmeding> Guest34200: that would be the Show instance of Pixel
2021-02-27 10:52:19 <tomsmeding> what's the type of those Pixel values?
2021-02-27 10:52:56 <tomsmeding> Guest34200: you might want to try https://hackage.haskell.org/package/hip-1.5.6.0/docs/Graphics-Image-Interface.html#v:toListPx ?
2021-02-27 10:53:26 <Guest34200> uh I wanted to get a 2d list of just the pixel values in double precision
2021-02-27 10:54:18 <Guest34200> so I guess i would use toListPx? but it seems that would only produce one list
2021-02-27 10:54:34 <tomsmeding> well you'd map that over your lists of pixels
2021-02-27 10:54:41 <tomsmeding> so map (map toListPx) (toList ...)
2021-02-27 10:55:03 <tomsmeding> but what that returns exactly will depend on the precise type of Pixel you have
2021-02-27 10:58:22 average joins (uid473595@gateway/web/irccloud.com/x-ojfayrlpvuxvtkja)
2021-02-27 10:59:05 <Guest34200> ah okay
2021-02-27 10:59:09 <Guest34200> thanks
2021-02-27 11:00:13 × troydm quits (~troydm@unaffiliated/troydm) (Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset)
2021-02-27 11:02:28 × emmanuel_erc quits (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com) (Read error: Connection reset by peer)
2021-02-27 11:02:47 × jpds_ quits (~jpds@gateway/tor-sasl/jpds) (Remote host closed the connection)
2021-02-27 11:02:58 da39a3ee5e6b4b0d joins (~da39a3ee5@2403:6200:8876:c8ae:4c2c:c3c0:6062:2fc9)
2021-02-27 11:03:01 emmanuel_erc joins (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com)
2021-02-27 11:03:23 jpds_ joins (~jpds@gateway/tor-sasl/jpds)
2021-02-27 11:04:50 × darjeeling_ quits (~darjeelin@122.245.218.150) (Ping timeout: 265 seconds)
2021-02-27 11:06:33 × danvet quits (~Daniel@2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa) (Ping timeout: 272 seconds)
2021-02-27 11:06:35 troydm joins (~troydm@unaffiliated/troydm)
2021-02-27 11:07:59 nhs joins (~nhs@ip68-2-235-160.ph.ph.cox.net)
2021-02-27 11:08:21 × kam1 quits (~kam1@5.125.126.175) (Ping timeout: 264 seconds)
2021-02-27 11:08:56 × haritz quits (~hrtz@unaffiliated/haritz) (Ping timeout: 240 seconds)
2021-02-27 11:09:28 × emmanuel_erc quits (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com) (Read error: Connection reset by peer)
2021-02-27 11:09:48 haritz joins (~hrtz@62.3.70.206)
2021-02-27 11:09:48 × haritz quits (~hrtz@62.3.70.206) (Changing host)
2021-02-27 11:09:48 haritz joins (~hrtz@unaffiliated/haritz)
2021-02-27 11:10:11 emmanuel_erc joins (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com)
2021-02-27 11:10:28 coot joins (~coot@37.30.55.141.nat.umts.dynamic.t-mobile.pl)
2021-02-27 11:12:59 × nhs quits (~nhs@ip68-2-235-160.ph.ph.cox.net) (Ping timeout: 256 seconds)
2021-02-27 11:13:18 borne joins (~fritjof@2a06:8782:ffbb:1337:2133:4ed6:e22f:c3eb)
2021-02-27 11:16:03 × emmanuel_erc quits (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com) (Read error: Connection reset by peer)
2021-02-27 11:16:23 coot_ joins (~coot@37.30.55.141.nat.umts.dynamic.t-mobile.pl)
2021-02-27 11:16:27 __monty__ joins (~toonn@unaffiliated/toonn)
2021-02-27 11:16:41 emmanuel_erc joins (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com)
2021-02-27 11:16:57 × bibek quits (~bibek@27.34.20.148) (Quit: WeeChat 3.0)
2021-02-27 11:17:08 Mrbuck joins (~Mrbuck@gateway/tor-sasl/mrbuck)
2021-02-27 11:17:15 × terrorjack quits (~terrorjac@ec2-52-47-143-92.eu-west-3.compute.amazonaws.com) (Quit: The Lounge - https://thelounge.chat)
2021-02-27 11:17:19 × fendor quits (~fendor@91.141.0.74.wireless.dyn.drei.com) (Remote host closed the connection)
2021-02-27 11:17:38 mouseghost joins (~draco@87-206-9-185.dynamic.chello.pl)
2021-02-27 11:17:38 × mouseghost quits (~draco@87-206-9-185.dynamic.chello.pl) (Changing host)
2021-02-27 11:17:38 mouseghost joins (~draco@wikipedia/desperek)
2021-02-27 11:17:42 <Guest34200> if I have a function foo that produces the 2d list constructed from the toList function, and I have another function bar that takes in a 2d list as an argument, how would I pass that 2d list produced by foo into bar? currently I have foo ( do stuff return (2dlist) and in main i'm trying to do bar (foo) but it's giving me type errors, saying it's
2021-02-27 11:17:43 <Guest34200> expecting IO[Double]. i don't have much experience with functional programming so I'm pretty sure I"m thinking about this the wrong way, can anyone point me in the right direction?
2021-02-27 11:19:33 <mouseghost> im not sure if you need the `return'
2021-02-27 11:19:56 <mouseghost> afaik it often refers to wrapping `a' into a monad
2021-02-27 11:19:57 <__monty__> Guest34200: Does producing the list require IO? (Btw, what do you mean when you say 2d? Because it looks like a flat list of Doubles.)
2021-02-27 11:20:40 × coot quits (~coot@37.30.55.141.nat.umts.dynamic.t-mobile.pl) (Ping timeout: 276 seconds)
2021-02-27 11:20:41 coot_ is now known as coot
2021-02-27 11:20:53 <mouseghost> nvm what i said..
2021-02-27 11:21:01 <tomsmeding> Guest34200: a function of type 'a -> b' needs an 'a' as input, not an 'IO a'
2021-02-27 11:21:09 <Guest34200> 2d list as in a nested list
2021-02-27 11:21:28 <tomsmeding> your foo, and the do-block containing foo, will be returning IO [[Pixel ...]]
2021-02-27 11:21:52 <Guest34200> right yeah
2021-02-27 11:21:53 <tomsmeding> since 'bar' needs a [[Pixel ...]], you'll need to work in the IO monad
2021-02-27 11:22:07 <Guest34200> yeah that's the exact error i was getting
2021-02-27 11:22:12 fendor joins (~fendor@91.141.0.74.wireless.dyn.drei.com)
2021-02-27 11:22:29 <tomsmeding> one way is: do res <- foo ... ; let output = bar res ; doSomethingWithOutput output
2021-02-27 11:22:38 <Axman6> No one escapes the Glasgow IO composition!
2021-02-27 11:22:45 × emmanuel_erc quits (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com) (Read error: Connection reset by peer)
2021-02-27 11:22:49 <tomsmeding> because in the do block, after unwrapping with <- , you can use the value as-is, without the IO wrapper
2021-02-27 11:23:13 <Guest34200> this is my foo: readImg img = do
2021-02-27 11:23:13 <Guest34200>     procImg <- I.readImageY I.VS img
2021-02-27 11:23:13 <Guest34200>     let newImg = I.toLists procImg
2021-02-27 11:23:14 <Guest34200>     return newImg
2021-02-27 11:23:19 <tomsmeding> a do-block is actually syntactic sugar: it's exactly equivalent to some usage of >>=
2021-02-27 11:23:24 <tomsmeding> :t (>>=)
2021-02-27 11:23:25 × _xor quits (~xor@74.215.46.133) (Quit: brb)
2021-02-27 11:23:25 <lambdabot> Monad m => m a -> (a -> m b) -> m b
2021-02-27 11:23:26 emmanuel_erc joins (~user@2603-7000-9600-01c9-c589-d024-9ed2-1840.res6.spectrum.com)
2021-02-27 11:23:28 kit joins (~kit@103.231.91.232)
2021-02-27 11:23:43 <tomsmeding> :t (>>=) :: IO a -> (a -> IO b) -> IO b
2021-02-27 11:23:44 <lambdabot> IO a -> (a -> IO b) -> IO b
2021-02-27 11:23:50 Franciman joins (~francesco@host-82-49-79-189.retail.telecomitalia.it)
2021-02-27 11:24:00 <Guest34200> oh
2021-02-27 11:24:16 × kit quits (~kit@103.231.91.232) (Client Quit)
2021-02-27 11:24:23 <tomsmeding> that 'IO a' would be the result of foo
2021-02-27 11:24:37 <tomsmeding> that 'a -> IO b' is another IO action that needs to use the result of foo
2021-02-27 11:24:41 <tomsmeding> i.e. bar
2021-02-27 11:25:00 <tomsmeding> if bar doesn't need to perform IO, you can just use the Functor instance of IO:
2021-02-27 11:25:07 <tomsmeding> :t fmap :: (a -> b) -> IO a -> IO b
2021-02-27 11:25:08 <lambdabot> (a -> b) -> IO a -> IO b
2021-02-27 11:25:20 <tomsmeding> fmap bar (readImg img)
2021-02-27 11:26:05 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)
2021-02-27 11:26:12 <xsperry> Guest12880, your code looks fine, assuming readImage returns IO something, and that toLists returns non-IO
2021-02-27 11:27:06 <Guest34200> readImage doesn't return IO i don't think but the function returns IO [[Graphics.Image.ColorSpace.Pixel Y Double]]
2021-02-27 11:27:24 <xsperry> what function?
2021-02-27 11:27:36 <xsperry> readImageY?
2021-02-27 11:27:38 <Guest34200> foo
2021-02-27 11:27:45 <Guest34200> readimageY is inside of foo
2021-02-27 11:28:00 <xsperry> what do readImageY and toLists return
2021-02-27 11:28:05 _xor joins (~xor@74.215.46.133)
2021-02-27 11:28:41 <Guest34200> oh wait
2021-02-27 11:28:46 <Guest34200> readImageY does return IO
2021-02-27 11:28:50 <Guest34200>  IO (Image VS Y Double)
2021-02-27 11:28:59 basoares joins (~basoares@2a04:ee41:4:2178:a846:18f7:81d4:249b)
2021-02-27 11:29:05 basoares_ joins (~basoares@2a04:ee41:4:2178:a846:18f7:81d4:249b)
2021-02-27 11:29:06 <Guest34200> to lists returns [[Pixel Y Double]]
2021-02-27 11:29:35 <xsperry> so your readImg function looks fine.. if you get errors post a test case, with error messages

All times are in UTC.