Logs: freenode/#haskell
| 2021-04-06 07:10:38 | × | Rudd0 quits (~Rudd0@185.189.115.108) (Ping timeout: 240 seconds) |
| 2021-04-06 07:12:08 | × | howdoi quits (uid224@gateway/web/irccloud.com/x-sykzqmpormchxxqk) (Quit: Connection closed for inactivity) |
| 2021-04-06 07:12:40 | → | gtk joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) |
| 2021-04-06 07:15:38 | × | nut quits (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Ping timeout: 246 seconds) |
| 2021-04-06 07:16:56 | × | srk quits (~sorki@2a00:1028:83a6:10aa:333a:80ef:9696:7eea) (Quit: ZNC 1.8.2 - https://znc.in) |
| 2021-04-06 07:18:04 | × | molehillish quits (~molehilli@2600:8800:8d06:1800:b54a:36bf:7632:87f4) (Remote host closed the connection) |
| 2021-04-06 07:19:03 | → | molehillish joins (~molehilli@2600:8800:8d06:1800:b54a:36bf:7632:87f4) |
| 2021-04-06 07:20:28 | × | frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 265 seconds) |
| 2021-04-06 07:20:37 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-04-06 07:20:49 | × | bgamari_ quits (~bgamari@2001:470:e438::1) (Ping timeout: 245 seconds) |
| 2021-04-06 07:21:01 | → | bgamari joins (~bgamari@72.65.102.162) |
| 2021-04-06 07:21:14 | → | Varis joins (~Tadas@unaffiliated/varis) |
| 2021-04-06 07:22:31 | → | kamotaketsunumin joins (6769235f@103.105.35.95) |
| 2021-04-06 07:22:31 | <kamotaketsunumin> | https://media.discordapp.net/attachments/747637197548552193/828892217254739978/Screenshot_20210406_142102.png?width=1213&height=669 |
| 2021-04-06 07:22:49 | <kamotaketsunumin> | What cause Maybe () instead of IO() in there? anyone know? |
| 2021-04-06 07:23:06 | × | minoru_shiraeesh quits (~shiraeesh@109.166.56.44) (Ping timeout: 240 seconds) |
| 2021-04-06 07:23:10 | <kamotaketsunumin> | I'm trying to desugar do notation |
| 2021-04-06 07:23:30 | <DigitalKiwi> | cabal-install-ghc74: Temporary version of cabal-install for ghc-7.4 |
| 2021-04-06 07:23:41 | × | molehillish quits (~molehilli@2600:8800:8d06:1800:b54a:36bf:7632:87f4) (Ping timeout: 245 seconds) |
| 2021-04-06 07:23:54 | <raehik> | kamotaketsunumin: lookup returns a Maybe |
| 2021-04-06 07:23:57 | <DigitalKiwi> | i do not think temporary means what they think it means |
| 2021-04-06 07:24:22 | <raehik> | looks like it's expecting the lambda on the end to return a Maybe because of that |
| 2021-04-06 07:24:27 | <DigitalKiwi> | is from 2012 lol |
| 2021-04-06 07:24:46 | <kamotaketsunumin> | how to return a Just instead? |
| 2021-04-06 07:24:52 | <kamotaketsunumin> | I though lookup is return Just |
| 2021-04-06 07:24:59 | <kamotaketsunumin> | from type signature I check it |
| 2021-04-06 07:25:05 | <raehik> | :t fromJust |
| 2021-04-06 07:25:07 | <lambdabot> | Maybe a -> a |
| 2021-04-06 07:25:12 | <kamotaketsunumin> | Oh no it's Maybe b |
| 2021-04-06 07:25:13 | <DigitalKiwi> | well, last one...copyright says 2005. all kinds of not temporary lol |
| 2021-04-06 07:25:16 | <kamotaketsunumin> | Eq a => a -> [(a, b)] -> Maybe b |
| 2021-04-06 07:25:24 | <kamotaketsunumin> | did I have to do case of ? |
| 2021-04-06 07:25:33 | <raehik> | your commented code essentially does fromJust via a pattern match so same thing |
| 2021-04-06 07:25:38 | → | mikoto-chan joins (~anass@gateway/tor-sasl/mikoto-chan) |
| 2021-04-06 07:25:43 | <raehik> | :t return . fromJust |
| 2021-04-06 07:25:44 | <lambdabot> | Monad m => Maybe a -> m a |
| 2021-04-06 07:25:53 | <raehik> | That gets you what you want (replace m with IO) |
| 2021-04-06 07:25:53 | <kamotaketsunumin> | what? |
| 2021-04-06 07:26:01 | × | royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 260 seconds) |
| 2021-04-06 07:26:12 | <kamotaketsunumin> | formJust ? |
| 2021-04-06 07:26:23 | × | Desmond373 quits (b49673ba@180.150.115.186) (Quit: Connection closed) |
| 2021-04-06 07:26:24 | <kamotaketsunumin> | what is fromJust here? |
| 2021-04-06 07:26:32 | <raehik> | fromJust takes a Maybe and returns the term stored in Just |
| 2021-04-06 07:26:40 | <raehik> | it takes a Maybe a and returns the a |
| 2021-04-06 07:26:46 | <raehik> | if it's Nothing, it errors out |
| 2021-04-06 07:26:59 | <kamotaketsunumin> | ahhh I see, lemme try. |
| 2021-04-06 07:27:10 | <kamotaketsunumin> | strange, it's not in Prelude? |
| 2021-04-06 07:27:17 | <kamotaketsunumin> | did I have to add module/library? |
| 2021-04-06 07:27:22 | <raehik> | so use fromJust to unwrap, and rewrap in IO with return |
| 2021-04-06 07:27:31 | <raehik> | yeah, import Data.Maybe (fromJust) |
| 2021-04-06 07:27:40 | <kamotaketsunumin> | ohh okay Data.Maybe, I got it. |
| 2021-04-06 07:27:46 | <raehik> | (Hoogle is handy for figuring out where to import things) |
| 2021-04-06 07:28:14 | <kamotaketsunumin> | hoogle is hard to explore? |
| 2021-04-06 07:28:18 | <kamotaketsunumin> | Am I the only one? |
| 2021-04-06 07:28:26 | <raehik> | https://hoogle.haskell.org/?hoogle=fromJust |
| 2021-04-06 07:29:05 | <raehik> | I think the UI is fine personally |
| 2021-04-06 07:29:32 | <raehik> | some features might be unclear I'll agree |
| 2021-04-06 07:30:32 | → | gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh) |
| 2021-04-06 07:31:46 | → | minoru_shiraeesh joins (~shiraeesh@109.166.56.44) |
| 2021-04-06 07:32:28 | <DigitalKiwi> | it took me years to find the Contents button on hackage |
| 2021-04-06 07:32:56 | → | mkDoku joins (~TheMule@aftr-37-201-195-134.unity-media.net) |
| 2021-04-06 07:33:16 | <kamotaketsunumin> | main = getArgs >>= \(command : args) -> fromJust (lookup command dispatch) args |
| 2021-04-06 07:33:16 | <kamotaketsunumin> | great |
| 2021-04-06 07:33:24 | <kamotaketsunumin> | it's just work |
| 2021-04-06 07:33:26 | <raehik> | nice! |
| 2021-04-06 07:33:28 | → | srk joins (~sorki@unaffiliated/srk) |
| 2021-04-06 07:33:59 | <raehik> | sometimes you can replace the fromJust lookup pattern with a function |
| 2021-04-06 07:34:14 | <raehik> | that way you can remove the fromJust and feel a bit safer |
| 2021-04-06 07:35:06 | <kamotaketsunumin> | emm really? I don't know what happen under fromJust, is there pattern matching behind it? the type signatur just Maybe a -> a |
| 2021-04-06 07:35:19 | <kamotaketsunumin> | safer means no error thrown right? |
| 2021-04-06 07:35:23 | <raehik> | yes, if you pass a Nothing to fromJust it throws a runtime error |
| 2021-04-06 07:35:27 | <kamotaketsunumin> | and the program crash |
| 2021-04-06 07:35:33 | <kamotaketsunumin> | yeah |
| 2021-04-06 07:35:53 | <raehik> | in your code it probably doesn't matter all that much because it would be a clear programmer error and probably happen early |
| 2021-04-06 07:36:09 | <raehik> | but it's good practice to avoid unsafe stuff where possible |
| 2021-04-06 07:36:23 | → | zaquest joins (~notzaques@5.128.210.178) |
| 2021-04-06 07:37:11 | <raehik> | try changing your `[(String, [String] -> IO ())]` to a `String -> ([String] -> IO ())` |
| 2021-04-06 07:37:22 | × | beka quits (~beka@gothdyke.mom) (Quit: ZNC 1.6.5+deb1+deb9u2 - http://znc.in) |
| 2021-04-06 07:37:34 | <kamotaketsunumin> | hstodo: Main.hs:30:20-79: Non-exhaustive patterns in lambda <= funny |
| 2021-04-06 07:38:02 | <kamotaketsunumin> | raehik why though? |
| 2021-04-06 07:38:10 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-04-06 07:38:31 | <raehik> | why change it? to clarify your types |
| 2021-04-06 07:38:34 | → | coot joins (~coot@37.30.55.131.nat.umts.dynamic.t-mobile.pl) |
| 2021-04-06 07:39:04 | → | kiweun joins (~kiweun@2607:fea8:2a62:9600:49c1:f7f6:7281:486d) |
| 2021-04-06 07:39:06 | <kamotaketsunumin> | so? no more lookup? |
| 2021-04-06 07:39:13 | <raehik> | no huge reason, it stood out to me because it was something I noticed in a codebase recently |
| 2021-04-06 07:39:32 | → | beka joins (~beka@gothdyke.mom) |
| 2021-04-06 07:39:49 | <raehik> | yes, you could replace `fromJust (lookup command dispatch) args` with `(dispatch command) args` |
| 2021-04-06 07:40:51 | <raehik> | you'll want to change the type as I mentioned, and the dispatch function should be `case cmd of "add" -> add` etc |
| 2021-04-06 07:41:24 | × | royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Client Quit) |
| 2021-04-06 07:41:36 | × | sayola quits (~vekto@dslb-002-201-085-157.002.201.pools.vodafone-ip.de) (Ping timeout: 245 seconds) |
| 2021-04-06 07:41:43 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-04-06 07:42:04 | <kamotaketsunumin> | ah, I use guard instead |
| 2021-04-06 07:42:57 | × | mikoto-chan quits (~anass@gateway/tor-sasl/mikoto-chan) (Quit: mikoto-chan) |
| 2021-04-06 07:43:00 | <raehik> | yep any way is fine |
| 2021-04-06 07:43:19 | → | mikoto-chan joins (~anass@gateway/tor-sasl/mikoto-chan) |
| 2021-04-06 07:43:19 | × | kiweun quits (~kiweun@2607:fea8:2a62:9600:49c1:f7f6:7281:486d) (Ping timeout: 258 seconds) |
| 2021-04-06 07:43:21 | <raehik> | if lambda case was default yet I would've said that, it's clearest and shortest |
| 2021-04-06 07:43:23 | <kamotaketsunumin> | ah the way dispatch store is in list, yeah perhaps it's good to just store dispatch as a Param(:t String) -> Command(:t [String] -> IO()) |
| 2021-04-06 07:43:25 | × | mikoto-chan quits (~anass@gateway/tor-sasl/mikoto-chan) (Client Quit) |
All times are in UTC.