Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-21 07:12:24 <Axman6> > (:) <$> Just 1 <*> Just []
2021-04-21 07:12:26 <lambdabot> Just [1]
2021-04-21 07:12:35 <Axman6> > (:) <$> Nothing <*> Just []
2021-04-21 07:12:37 <lambdabot> Nothing
2021-04-21 07:12:39 leothrix joins (~leothrix@elastic/staff/leothrix)
2021-04-21 07:12:46 <Axman6> > (:) <$> Just 1 <*> Nithing
2021-04-21 07:12:48 <lambdabot> error:
2021-04-21 07:12:48 <lambdabot> • Data constructor not in scope: Nithing :: Maybe [a]
2021-04-21 07:12:48 <lambdabot> • Perhaps you meant one of these:
2021-04-21 07:12:54 <Axman6> > (:) <$> Just 1 <*> Nothing
2021-04-21 07:12:56 <lambdabot> Nothing
2021-04-21 07:13:45 <guest421> Axman6: how "collect the results" ?
2021-04-21 07:14:16 <Axman6> it collects all the successful results
2021-04-21 07:14:19 <guest421> [] is an instance of Traversable?
2021-04-21 07:14:21 <Axman6> I think you want catMaybes
2021-04-21 07:14:25 × dpl_ quits (~dpl@77-121-78-163.chn.volia.net) (Ping timeout: 268 seconds)
2021-04-21 07:14:27 <Axman6> :t catMaybes
2021-04-21 07:14:29 <lambdabot> [Maybe a] -> [a]
2021-04-21 07:14:33 × howdoi quits (uid224@gateway/web/irccloud.com/x-bcrpbrlexhkfsmvn) (Quit: Connection closed for inactivity)
2021-04-21 07:14:48 <Axman6> > catMaybes [Nothing, Just a, Nothing, Just 2]
2021-04-21 07:14:50 <lambdabot> [a,2]
2021-04-21 07:14:57 <Axman6> > catMaybes [Nothing, Just 1, Nothing, Just 2]
2021-04-21 07:15:00 <lambdabot> [1,2]
2021-04-21 07:15:01 dyeplexer joins (~lol@unaffiliated/terpin)
2021-04-21 07:15:40 dpl_ joins (~dpl@77-121-78-163.chn.volia.net)
2021-04-21 07:16:30 × vdukhovni quits (64022765@100.2.39.101) (Quit: Connection closed)
2021-04-21 07:17:41 <guest421> Axman6: fetchUrl :: Url -> MaybeT IO a, traverse (runMaybeT . fetchUrl) [Url1, Url2] -- this will return a list contain [Just a, Nothing...] or Just [a]?
2021-04-21 07:18:12 <Axman6> what does ghci tell you? what's the type of runMaybeT . fetchUrl?
2021-04-21 07:18:20 × Sgeo quits (~Sgeo@ool-18b98aa4.dyn.optonline.net) (Read error: Connection reset by peer)
2021-04-21 07:18:29 <Axman6> should be Url -> IO (Maybe a) right?
2021-04-21 07:18:44 <guest421> Axman6: yeah, that's simple
2021-04-21 07:18:45 idhugo__ joins (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net)
2021-04-21 07:18:49 <Axman6> so the result will be IO [Maybe a]
2021-04-21 07:19:01 <Axman6> do you want to fail if any fetch fails?
2021-04-21 07:19:08 <guest421> yes
2021-04-21 07:20:41 <Axman6> then you probably want runMaybeT $ traverse fetchUrl [Url1, Url2], which will give you back an IO (Maybe [a])
2021-04-21 07:21:14 idhugo_ joins (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net)
2021-04-21 07:21:49 × bitmagie quits (~Thunderbi@200116b8063572001499edd4f9d505b9.dip.versatel-1u1.de) (Quit: bitmagie)
2021-04-21 07:22:12 × sleblanc quits (~sleblanc@unaffiliated/sebleblanc) (Ping timeout: 240 seconds)
2021-04-21 07:23:32 × idhugo__ quits (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net) (Ping timeout: 240 seconds)
2021-04-21 07:24:29 <guest421> fetchUrl :: Url -> IO (Maybe a)
2021-04-21 07:24:32 × nineonine quits (~nineonine@50.216.62.2) (Ping timeout: 240 seconds)
2021-04-21 07:25:03 <Axman6> well that's different to MaybeT IO a
2021-04-21 07:25:11 <guest421> fmap fetchUrl [Url] :: [IO (Maybe a)]
2021-04-21 07:25:16 × loller_ quits (uid358106@gateway/web/irccloud.com/x-jiaqaybiuqrwtvzc) (Quit: Connection closed for inactivity)
2021-04-21 07:25:34 <guest421> sequence . fmap $ fetchUrl [Url] :: ?
2021-04-21 07:25:42 knupfer joins (~Thunderbi@i59F67B5A.versanet.de)
2021-04-21 07:26:04 <Axman6> that doesn't make sense
2021-04-21 07:26:25 <guest421> Axman6: which part?
2021-04-21 07:27:22 <guest421> sequence (a :: [IO (Maybe a)]) :: ?
2021-04-21 07:27:57 <guest421> :t sequence
2021-04-21 07:27:58 <lambdabot> (Traversable t, Monad m) => t (m a) -> m (t a)
2021-04-21 07:28:00 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-04-21 07:28:39 <Axman6> :t sequence `asAppledTo` (undefined :: [IO (Maybe a])
2021-04-21 07:28:41 <lambdabot> error: parse error on input ‘]’
2021-04-21 07:28:47 <Axman6> :t sequence `asAppledTo` (undefined :: [IO (Maybe a)])
2021-04-21 07:28:49 <lambdabot> error:
2021-04-21 07:28:49 <lambdabot> • Variable not in scope:
2021-04-21 07:28:49 <lambdabot> asAppledTo :: (t0 (m0 a0) -> m0 (t0 a0)) -> [IO (Maybe a1)] -> t
2021-04-21 07:28:50 × Codaraxis__ quits (Codaraxis@gateway/vpn/mullvad/codaraxis) (Ping timeout: 246 seconds)
2021-04-21 07:29:01 <c_wraith> try asAppliedTo :P
2021-04-21 07:29:06 <Axman6> :t sequence `asAppliedTo` (undefined :: [IO (Maybe a)])
2021-04-21 07:29:08 <lambdabot> [IO (Maybe a)] -> IO [Maybe a]
2021-04-21 07:29:44 <guest421> sequence . fmap $ fetchUrl [Url] :: IO [Maybe a] ?
2021-04-21 07:29:45 <Axman6> guest421: so you could so fmap sequence . sequence if you want an IO (Maybe [a])
2021-04-21 07:30:03 <Axman6> :t fmap sequence . sequence `asAppliedTo` (undefined :: [IO (Maybe a)])
2021-04-21 07:30:05 <lambdabot> [IO (Maybe a)] -> IO (Maybe [a])
2021-04-21 07:30:07 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-04-21 07:31:28 <guest421> why sequence . sequence...
2021-04-21 07:32:38 <Axman6> it's (fmap sequence) . sequence, it's applying sequence to the [Maybe a] returned by the IO, it's doing: fmap sequence :: IO [Maybe a] -> IO (Maybe [a])
2021-04-21 07:36:07 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 252 seconds)
2021-04-21 07:38:27 nut_ joins (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr)
2021-04-21 07:40:45 <Axman6> so fmap sequence . sequence first turns a [IO (Maybe a)] into an IO [Maybe a], and then into an IO (Maybe [a])
2021-04-21 07:40:55 hypercube joins (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com)
2021-04-21 07:41:03 × hypercube quits (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com) (Client Quit)
2021-04-21 07:43:28 hypercube joins (hypercube@gateway/vpn/protonvpn/hypercube)
2021-04-21 07:43:35 × hypercube quits (hypercube@gateway/vpn/protonvpn/hypercube) (Client Quit)
2021-04-21 07:44:18 Sornaensis joins (~Sornaensi@077213200034.dynamic.telenor.dk)
2021-04-21 07:46:52 Sorna joins (~Sornaensi@79.142.232.102)
2021-04-21 07:48:23 benkolera joins (uid285671@gateway/web/irccloud.com/x-uqnaygwihchxqkys)
2021-04-21 07:48:55 <maerwald> now I want an `IO (Maybe a)` ;)
2021-04-21 07:49:04 <maerwald> and then an IO a
2021-04-21 07:49:32 × Sornaensis quits (~Sornaensi@077213200034.dynamic.telenor.dk) (Ping timeout: 240 seconds)
2021-04-21 07:50:11 × nut_ quits (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Read error: Connection reset by peer)
2021-04-21 07:50:35 <Axman6> best I can do fer ya as a Monoid a constraint
2021-04-21 07:50:37 nut_ joins (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr)
2021-04-21 07:53:37 <maralorn> (>>= \case {Just (x:_) -> pure x; _ -> throwIO "Nothing to return") :: IO (Maybe [a]) -> IO a
2021-04-21 07:53:46 <maralorn> * (>>= \case {Just (x:_) -> pure x; _ -> throwIO "Nothing to return"}) :: IO (Maybe [a]) -> IO a
2021-04-21 07:54:15 <Axman6> um could you not? :P
2021-04-21 07:54:32 × nut quits (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Remote host closed the connection)
2021-04-21 07:54:56 guest421` joins (~user@47.245.54.240)
2021-04-21 07:55:26 m0rphism joins (~m0rphism@HSI-KBW-085-216-104-059.hsi.kabelbw.de)
2021-04-21 07:56:11 paddymahoney joins (~paddymaho@cpe9050ca207f83-cm9050ca207f80.cpe.net.cable.rogers.com)
2021-04-21 07:56:20 Lowl3v3l joins (~Lowl3v3l@dslb-002-207-103-026.002.207.pools.vodafone-ip.de)
2021-04-21 07:59:13 × guest421 quits (~user@49.5.6.87) (Ping timeout: 252 seconds)
2021-04-21 08:01:31 × evanjs quits (~evanjs@075-129-098-007.res.spectrum.com) (Read error: Connection reset by peer)
2021-04-21 08:03:10 cfricke joins (~cfricke@unaffiliated/cfricke)
2021-04-21 08:03:18 evanjs joins (~evanjs@075-129-098-007.res.spectrum.com)
2021-04-21 08:03:51 geowiesnot joins (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr)
2021-04-21 08:04:23 MVQq joins (~anja@198.254.208.159)

All times are in UTC.