Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-21 04:16:58 <yahb> Axman6: unknown command ':traverse'; use :? for help.
2021-04-21 04:17:03 <Axman6> % :t traverse @Tree @IO
2021-04-21 04:17:03 <yahb> Axman6: (a -> IO b) -> Tree a -> IO (Tree b)
2021-04-21 04:18:28 <guest421> > traverse print [1,2,3]
2021-04-21 04:18:30 <lambdabot> <IO [()]>
2021-04-21 04:20:17 Rudd0 joins (~Rudd0@185.189.115.108)
2021-04-21 04:23:41 ania123 joins (5e89ad7c@94.137.173.124)
2021-04-21 04:24:24 j_lazy joins (~lazy_J@64.44.80.252)
2021-04-21 04:25:58 <guest421> like sequenceA_ (fmap print [1,2,3])?
2021-04-21 04:26:04 nineonine joins (~nineonine@50.216.62.2)
2021-04-21 04:26:14 <guest421> :t sequenceA_
2021-04-21 04:26:16 <lambdabot> (Foldable t, Applicative f) => t (f a) -> f ()
2021-04-21 04:26:26 × fresheyeball quits (~isaac@c-71-237-105-37.hsd1.co.comcast.net) (Quit: WeeChat 2.9)
2021-04-21 04:26:36 × lazy_j quits (~lazy_J@193.27.12.44) (Ping timeout: 245 seconds)
2021-04-21 04:26:39 <guest421> but this t is Foldable not Traversable
2021-04-21 04:28:02 falafel_ joins (~falafel@pool-96-255-70-50.washdc.fios.verizon.net)
2021-04-21 04:28:08 × ortz quits (~egigs@108-89-5-25.lightspeed.dybhfl.sbcglobal.net) (Quit: leaving)
2021-04-21 04:28:32 × horatiohb quits (~horatiohb@104.131.33.15) (Ping timeout: 240 seconds)
2021-04-21 04:28:46 × j_lazy quits (~lazy_J@64.44.80.252) (Ping timeout: 240 seconds)
2021-04-21 04:31:35 aVikingTrex joins (~aVikingTr@2001:8003:340d:d00:b2de:b98:7a93:b0ea)
2021-04-21 04:32:49 pfurla joins (~pfurla@ool-182ed2e2.dyn.optonline.net)
2021-04-21 04:33:03 <guest421> I forget how to put IO actions inside a list?
2021-04-21 04:33:07 × pfurla quits (~pfurla@ool-182ed2e2.dyn.optonline.net) (Client Quit)
2021-04-21 04:34:00 × jesystani quits (~thorn@2404:4404:17f1:4900:321c:1a26:59b4:eb2d) (Quit: WeeChat 3.1)
2021-04-21 04:34:49 pfurla joins (~pfurla@ool-182ed2e2.dyn.optonline.net)
2021-04-21 04:36:04 <glguy> :t [ print "IO", print "actions" ]
2021-04-21 04:36:05 <lambdabot> [IO ()]
2021-04-21 04:36:16 × hypercube quits (hypercube@gateway/vpn/protonvpn/hypercube) (Ping timeout: 252 seconds)
2021-04-21 04:39:12 × RusAlex quits (~Chel@unaffiliated/rusalex) (Ping timeout: 265 seconds)
2021-04-21 04:40:41 <Axman6> g`so the mental model you should use for traverse is, if I have a function which can accept a's and produce f b's (let's say, fetchUrl :: Url -> IO ByteString), and we have some traversable structure of containing a's (let's say urlTree :: Tree Url), then you can use traverse fetchUrl urlTree to get back an IO (Tree ByteString)
2021-04-21 04:40:55 u0_a203 joins (~u0_a203@93.119.221.33)
2021-04-21 04:41:50 × u0_a203 quits (~u0_a203@93.119.221.33) (Client Quit)
2021-04-21 04:42:37 <Axman6> guest421: ^ that was for you, but apparently I'm terrible at typing
2021-04-21 04:42:46 × MVQq quits (~anja@198.254.208.159) (Quit: q)
2021-04-21 04:43:24 MarcelineVQ joins (~anja@198.254.208.159)
2021-04-21 04:43:35 waleee-cl joins (uid373333@gateway/web/irccloud.com/x-bpfgsdmlrafbmgyu)
2021-04-21 04:43:55 <guest421> sequence $ fmap print [1,2,3]
2021-04-21 04:44:01 <guest421> mapM print [1,2,3]
2021-04-21 04:44:07 <Axman6> traverse f = sequence . fmap f
2021-04-21 04:44:18 <Axman6> mapM is also the same as traverse
2021-04-21 04:44:27 <c_wraith> Though really, you're probably better off with mapM_ or traverse_
2021-04-21 04:44:34 <guest421> traverse print [1,2,3]
2021-04-21 04:45:07 <guest421> sequenceA_ (fmap print [1,2,3])
2021-04-21 04:45:30 <Axman6> :t traverse_
2021-04-21 04:45:32 <lambdabot> (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
2021-04-21 04:46:46 <gnumonic> :t mapM
2021-04-21 04:46:47 <lambdabot> (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
2021-04-21 04:46:53 <Axman6> % sequenceA_ (fmap print [1,2,3])
2021-04-21 04:46:53 <yahb> Axman6: 1; 2; 3
2021-04-21 04:47:06 <gnumonic> huh i always thought mapM was specialized to lists
2021-04-21 04:47:07 <Axman6> % traverse_ print [1,2,3]
2021-04-21 04:47:07 <yahb> Axman6: 1; 2; 3
2021-04-21 04:47:08 <gnumonic> oops
2021-04-21 04:47:46 <Axman6> it used to be, but these days mapM etc are basically just old names for other function
2021-04-21 04:47:49 abhixec joins (~abhixec@c-67-169-139-16.hsd1.ca.comcast.net)
2021-04-21 04:48:28 <lechner> Hi, is there a consistent link to Haddock documentation on Hackage pages, please? https://hackage.haskell.org/package/zeromq4-haskell
2021-04-21 04:48:41 <guest421> those functions related to IO?
2021-04-21 04:48:42 <Axman6> consistent how?
2021-04-21 04:49:09 <Axman6> IO is an Applicative, so you can choose for the f to be IO
2021-04-21 04:49:20 <Axman6> (or m in the case of mapM etc)
2021-04-21 04:49:45 <guest421> fmap print [1,2,3] is not wrong, right?
2021-04-21 04:50:20 <c_wraith> it's not a type error. whether it's "wrong" or not depends on what you want to do. It won't create an IO action that prints each value.
2021-04-21 04:50:29 <guest421> but sequence or mapM or traverse will get the IO effects
2021-04-21 04:50:35 <guest421> which fmap print [1,2,3] won't
2021-04-21 04:50:46 <c_wraith> It will create a list of IO actions, rather than one IO action that prints everything in the list
2021-04-21 04:50:55 <c_wraith> sometimes you want a list of IO actions!
2021-04-21 04:51:33 <Axman6> :t fmap print
2021-04-21 04:51:35 <lambdabot> (Functor f, Show a) => f a -> f (IO ())
2021-04-21 04:51:36 <guest421> fmap print [1,2,3] would create a list of IO actions
2021-04-21 04:51:44 <Axman6> % :t fmap @[] print
2021-04-21 04:51:44 <yahb> Axman6: Show a => [a] -> [IO ()]
2021-04-21 04:51:50 <Axman6> yes
2021-04-21 04:52:11 <guest421> and what traverse or sequence or mapM do?
2021-04-21 04:52:22 <lechner> Axman6: i only see links sometimes. is there any documentation for the module above?
2021-04-21 04:52:22 <guest421> why there're so many names...
2021-04-21 04:52:40 <c_wraith> there are so many names because of historical mistakes
2021-04-21 04:52:51 × carlomagno quits (~cararell@148.87.23.7) (Remote host closed the connection)
2021-04-21 04:53:08 <Axman6> lechner: probably because it failed to build when uploaded to hackage so the documentation was never generated
2021-04-21 04:53:20 <lechner> Axman6: thanks!
2021-04-21 04:53:34 <c_wraith> Haskell is a pretty old language, and people have been trying to improve it for a long time. But sometimes that means when a clear improvement is made, old names stick around to not break old code
2021-04-21 04:53:41 <Axman6> lechner: look at the "build log" link at the bottom right of the page
2021-04-21 04:54:07 <lechner> Axman6: now i see it. thanks!
2021-04-21 04:55:24 <lechner> Axman6: maybe hackage could build the docs first... https://hackage.haskell.org/package/zeromq4-haskell-0.8.0/reports/2
2021-04-21 04:55:58 <Axman6> guest421: it's definitely more common to want to apply a function to every element of a list and then execute the resultin IO actions than it is to keep around a list of IO actions
2021-04-21 04:56:14 <Axman6> lechner: the docs building depend on the code being able to compile IIRC
2021-04-21 04:56:25 malumore_ joins (~malumore@151.62.122.70)
2021-04-21 04:57:15 <lechner> Axman6: yeah it looks like a broader cabal v1 problem, too https://hackage.haskell.org/package/zeromq4-simple-0.0.0.2/reports/3
2021-04-21 04:58:11 × jao quits (~jao@pdpc/supporter/professional/jao) (Ping timeout: 240 seconds)
2021-04-21 04:58:22 <Axman6> lechner: looks to me like the server hackage is running on doesn't have libzmq installed: (conflict:
2021-04-21 04:58:25 <Axman6> pkg-config package libzmq>=4.0 && <5.0, not found in the pkg-config database)
2021-04-21 04:58:49 <Axman6> which makes sense. Libraries which depend on external C libraries often fail to build on hackage
2021-04-21 04:59:26 <lechner> i see. that would explain why i could not find any ZeroMQ packages with documentation at all there
2021-04-21 04:59:38 × ania123 quits (5e89ad7c@94.137.173.124) (Quit: Connection closed)
2021-04-21 04:59:50 Jd007 joins (~Jd007@162.156.11.151)
2021-04-21 05:05:44 RusAlex joins (~Chel@unaffiliated/rusalex)
2021-04-21 05:09:02 _ht joins (~quassel@82-169-194-8.biz.kpn.net)
2021-04-21 05:16:19 Guest78317 joins (~laudiacay@67.176.215.84)
2021-04-21 05:19:56 × Tario quits (~Tario@201.192.165.173) (Ping timeout: 245 seconds)
2021-04-21 05:22:40 × maroloccio quits (~marolocci@pousada3ja.mma.com.br) (Quit: WeeChat 2.3)
2021-04-21 05:25:03 HannaM joins (~quassel@p54849510.dip0.t-ipconnect.de)

All times are in UTC.