Logs: liberachat/#haskell
| 2021-08-08 15:12:47 | <fgaz> | tomsmeding dsal: thanks! |
| 2021-08-08 15:13:17 | <tomsmeding> | it can get fairly large :p |
| 2021-08-08 15:13:43 | <Cajun> | lechner: given the type signature, both are `[String]` . and by convention, anything that ends with _ disregards results and returns `()` (at least as far as im aware) |
| 2021-08-08 15:14:59 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-08-08 15:15:46 | <lechner> | Cajun: thanks! i was actually confused by the statement "each call to putStrLn returns a unit" but my question did not reflect that very well. What is a unit, please? |
| 2021-08-08 15:16:00 | <tromp> | thx, @lechner. changed to "game of Go" |
| 2021-08-08 15:16:06 | <Cajun> | "unit" means `()` |
| 2021-08-08 15:16:37 | <lechner> | Cajun: thank you! |
| 2021-08-08 15:16:38 | <Cajun> | idk how to use lambda bot but `:t ()` === `() :: ()` |
| 2021-08-08 15:17:03 | <tomsmeding> | :t () |
| 2021-08-08 15:17:04 | <lambdabot> | () |
| 2021-08-08 15:17:08 | <Cajun> | and you can see this in mapM_'s type |
| 2021-08-08 15:17:11 | <Cajun> | :t mapM_ |
| 2021-08-08 15:17:12 | <lambdabot> | (Foldable t, Monad m) => (a -> m b) -> t a -> m () |
| 2021-08-08 15:17:28 | <Cajun> | well isnt that simple... :P |
| 2021-08-08 15:17:54 | <tomsmeding> | if confused by the Foldable, imagine t = [] so that mapM_ :: Monad m => (a -> m b) -> [a] -> m () |
| 2021-08-08 15:18:12 | → | peterhil joins (~peterhil@dsl-hkibng32-54fb52-57.dhcp.inet.fi) |
| 2021-08-08 15:19:02 | <Cajun> | and in this instance the monad is IO, so you can replace the m with IO for `(a -> IO b) -> [a] -> IO ()` or even more specifically `(String -> IO b) -> [String] -> IO ()` |
| 2021-08-08 15:19:22 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 240 seconds) |
| 2021-08-08 15:19:27 | <lechner> | i was confused that anyone would use mapM (without the underscore) but then also do not understand how a list of units is different from a plain unit |
| 2021-08-08 15:19:54 | × | oxide quits (~lambda@user/oxide) (Ping timeout: 240 seconds) |
| 2021-08-08 15:20:01 | <lechner> | it's just about the signature! |
| 2021-08-08 15:20:03 | → | Dumbfoundde4d joins (~Dumbfound@li480-24.members.linode.com) |
| 2021-08-08 15:20:13 | <Cajun> | sometimes you just want a list of monadic things *shrug* |
| 2021-08-08 15:20:25 | <geekosaur> | you don't normally use mapM when you're getting a list of units. but consider something that returns IO String |
| 2021-08-08 15:20:36 | <lechner> | right |
| 2021-08-08 15:21:00 | <Cajun> | but yeah `mapM` and `mapM_` function identically except with return values |
| 2021-08-08 15:21:01 | <tomsmeding> | with an imaginary 'performRequest :: Request -> IO Result', you might have 'mapM performRequests :: [Request] -> IO [Result]' |
| 2021-08-08 15:21:24 | × | cheater quits (~Username@user/cheater) (Ping timeout: 250 seconds) |
| 2021-08-08 15:21:47 | → | jakalx joins (~jakalx@base.jakalx.net) |
| 2021-08-08 15:22:48 | → | zmt00 joins (~zmt00@user/zmt00) |
| 2021-08-08 15:23:00 | <lechner> | so i'm making baby steps here. is there a way to restyle mapM_ putStrLn x into something involving the >>= putStrLn operator? |
| 2021-08-08 15:23:25 | × | philosomnaugh quits (~mnrmnaugh@68.162.206.56) (Remote host closed the connection) |
| 2021-08-08 15:23:39 | skykanin | is now known as Guest4303 |
| 2021-08-08 15:23:39 | × | Guest4303 quits (~skykanin@115.81-166-221.customer.lyse.net) (Killed (erbium.libera.chat (Nickname regained by services))) |
| 2021-08-08 15:23:50 | <lechner> | or is that a bogus thought |
| 2021-08-08 15:23:56 | → | mnrmnaugh joins (~mnrmnaugh@68.162.206.56) |
| 2021-08-08 15:23:57 | → | Guest4303 joins (~skykanin@115.81-166-221.customer.lyse.net) |
| 2021-08-08 15:24:39 | <Cajun> | yeah, heres a small example `foo = getLine >>= \line -> putStrLn line` although this can be more optimized |
| 2021-08-08 15:25:28 | → | skykanin joins (~skykanin@159.84-234-142.customer.lyse.net) |
| 2021-08-08 15:25:39 | × | skykanin quits (~skykanin@159.84-234-142.customer.lyse.net) (Client Quit) |
| 2021-08-08 15:25:40 | <Cajun> | well hlint doesnt yell at me for the code so its fine lol |
| 2021-08-08 15:25:49 | <tomsmeding> | lechner: if you have 'mapM_ putStrLn x', then x is a list of strings. So somehow, you're going to have to loop over the list x |
| 2021-08-08 15:26:01 | <tomsmeding> | mapM_ does this for you; you can also do it manually |
| 2021-08-08 15:26:49 | <tomsmeding> | :t let loop [] = return () ; loop (x:xs) = putStrLn x >> loop xs in loop |
| 2021-08-08 15:26:50 | <lambdabot> | [String] -> IO () |
| 2021-08-08 15:27:31 | <tomsmeding> | which you can express using standard functions like foldr in a number of ways :) |
| 2021-08-08 15:27:51 | → | Lycurgus joins (~juan@cpe-45-46-140-49.buffalo.res.rr.com) |
| 2021-08-08 15:28:00 | <tomsmeding> | (or traverse, which happens to be the same as mapM) |
| 2021-08-08 15:28:42 | <lechner> | i see. thanks! |
| 2021-08-08 15:28:46 | <Cajun> | i was thinking of doing something with traverse until i realized `mapM` already puts the monad on the outside of the list :p |
| 2021-08-08 15:29:26 | <tomsmeding> | traverse = mapM |
| 2021-08-08 15:29:49 | <Cajun> | oh yeah.. i guess it does wind up like that huh |
| 2021-08-08 15:30:02 | <tomsmeding> | well, with different typeclass constraints, and technically traverse is implemented using the Applicative combinators whereas mapM uses the monad methods |
| 2021-08-08 15:30:13 | <tomsmeding> | but if your instances are lawful, that should be exactly the same :) |
| 2021-08-08 15:30:45 | → | fendor joins (~fendor@213162073215.public.t-mobile.at) |
| 2021-08-08 15:30:46 | <Cajun> | "but if your instance are lawful" that sounds like it could be a headache and a half lol |
| 2021-08-08 15:30:49 | <tomsmeding> | also fmap = liftM |
| 2021-08-08 15:31:07 | <Lycurgus> | is there a quicklaw? |
| 2021-08-08 15:31:34 | <tomsmeding> | Lycurgus: https://hackage.haskell.org/package/tasty-quickcheck-laws |
| 2021-08-08 15:31:38 | × | euandreh quits (~euandreh@2804:14c:33:9fe5:9814:dfa2:8237:3c5c) (Quit: WeeChat 3.2) |
| 2021-08-08 15:31:44 | <Lycurgus> | tomsmeding, ty! |
| 2021-08-08 15:37:37 | deadletter[m] | is now known as stoicswe[m] |
| 2021-08-08 15:39:37 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-08-08 15:41:28 | → | fendor_ joins (~fendor@046125250027.public.t-mobile.at) |
| 2021-08-08 15:43:52 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 245 seconds) |
| 2021-08-08 15:43:52 | × | fendor quits (~fendor@213162073215.public.t-mobile.at) (Ping timeout: 245 seconds) |
| 2021-08-08 15:48:35 | → | tzh joins (~tzh@c-24-21-73-154.hsd1.or.comcast.net) |
| 2021-08-08 15:49:24 | ← | Dumbfoundde4d parts (~Dumbfound@li480-24.members.linode.com) (Later) |
| 2021-08-08 15:50:36 | → | marsupilami joins (~martin@2a01:e0a:43:72e0:b22a:9a5f:889c:554b) |
| 2021-08-08 15:52:26 | × | xff0x quits (~xff0x@2001:1a81:533f:2500:9e0:616e:42de:43f7) (Ping timeout: 256 seconds) |
| 2021-08-08 15:53:08 | → | xff0x joins (~xff0x@2001:1a81:533f:2500:f78f:6771:9432:cc40) |
| 2021-08-08 15:54:13 | × | marsupilami quits (~martin@2a01:e0a:43:72e0:b22a:9a5f:889c:554b) (Client Quit) |
| 2021-08-08 15:55:41 | → | ubert joins (~Thunderbi@178.115.34.26.wireless.dyn.drei.com) |
| 2021-08-08 15:58:34 | × | Lycurgus quits (~juan@cpe-45-46-140-49.buffalo.res.rr.com) (Quit: Exeunt) |
| 2021-08-08 15:59:53 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-08-08 15:59:57 | → | MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com) |
| 2021-08-08 16:01:14 | × | ubert quits (~Thunderbi@178.115.34.26.wireless.dyn.drei.com) (Remote host closed the connection) |
| 2021-08-08 16:04:17 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 245 seconds) |
| 2021-08-08 16:04:20 | × | epolanski quits (uid312403@id-312403.brockwell.irccloud.com) (Quit: Connection closed for inactivity) |
| 2021-08-08 16:04:36 | → | jgeerds joins (~jgeerds@55d45555.access.ecotel.net) |
| 2021-08-08 16:07:21 | × | jess quits (~jess@libera/staff/jess) () |
| 2021-08-08 16:14:37 | × | geekosaur quits (~geekosaur@xmonad/geekosaur) (Remote host closed the connection) |
| 2021-08-08 16:14:56 | → | geekosaur joins (~geekosaur@xmonad/geekosaur) |
| 2021-08-08 16:15:32 | <dsal> | Oh interesting. I was using checkers for that. |
| 2021-08-08 16:16:42 | × | vysn quits (~vysn@user/vysn) (Ping timeout: 240 seconds) |
| 2021-08-08 16:16:49 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-08-08 16:17:38 | <dsal> | testApplicativeLaws :: (Applicative f, Eq a, Eq b, Eq c, Show a, Show t, Show (f a), Show (f (a -> b)), Show (f (b -> c)), Arbitrary a, Arbitrary b, Arbitrary t, Arbitrary (f a), Arbitrary (f (a -> b)), Arbitrary (f (b -> c)), CoArbitrary a, Typeable f, Typeable a, Typeable b, Typeable c) => Proxy f -> Proxy t -> Proxy a -> Proxy b -> Proxy c -> (forall u. Eq u => t -> f u -> f u -> Bool) -> TestTree |
| 2021-08-08 16:17:45 | <dsal> | Well that doesn't look significantly easier to use. |
| 2021-08-08 16:18:06 | <dsal> | (not that I ever remember how to use checkers) |
| 2021-08-08 16:18:59 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 252 seconds) |
| 2021-08-08 16:19:57 | × | wei2912 quits (~wei2912@112.199.250.21) (Quit: Lost terminal) |
| 2021-08-08 16:20:08 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-08-08 16:22:30 | × | azeem quits (~azeem@dynamic-adsl-78-13-247-121.clienti.tiscali.it) (Ping timeout: 250 seconds) |
| 2021-08-08 16:22:52 | → | azeem joins (~azeem@176.201.28.221) |
| 2021-08-08 16:24:10 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 240 seconds) |
| 2021-08-08 16:25:19 | → | econo joins (uid147250@user/econo) |
| 2021-08-08 16:27:11 | × | azeem quits (~azeem@176.201.28.221) (Read error: Connection reset by peer) |
| 2021-08-08 16:27:23 | → | azeem joins (~azeem@dynamic-adsl-78-13-247-121.clienti.tiscali.it) |
| 2021-08-08 16:29:26 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 252 seconds) |
All times are in UTC.