Logs: freenode/#haskell
| 2020-09-24 13:37:06 | × | ystael quits (~ystael@209.6.50.55) (Quit: Lost terminal) |
| 2020-09-24 13:37:24 | <Xnuk> | bye |
| 2020-09-24 13:39:11 | → | ahmr88 joins (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) |
| 2020-09-24 13:39:48 | → | ystael joins (~ystael@209.6.50.55) |
| 2020-09-24 13:40:06 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 256 seconds) |
| 2020-09-24 13:41:12 | → | Dolly joins (585fd1fd@ti0203q160-5312.bb.online.no) |
| 2020-09-24 13:41:36 | × | Dolly quits (585fd1fd@ti0203q160-5312.bb.online.no) (Remote host closed the connection) |
| 2020-09-24 13:41:51 | × | filwisher quits (~filwisher@cpc76738-dals23-2-0-cust186.20-2.cable.virginm.net) (Quit: leaving) |
| 2020-09-24 13:43:32 | → | Dolly joins (585fd1fd@ti0203q160-5312.bb.online.no) |
| 2020-09-24 13:43:36 | × | ahmr88 quits (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) (Ping timeout: 260 seconds) |
| 2020-09-24 13:44:07 | → | adamwespiser joins (~adam_wesp@209.6.42.110) |
| 2020-09-24 13:44:25 | × | jneira[m] quits (~jneira@242.red-176-83-10.dynamicip.rima-tde.net) (Read error: Connection reset by peer) |
| 2020-09-24 13:44:46 | → | jneira[m] joins (~jneira@80.30.101.206) |
| 2020-09-24 13:45:11 | → | ransom joins (~c4264035@c-73-243-2-10.hsd1.co.comcast.net) |
| 2020-09-24 13:45:25 | × | ransom quits (~c4264035@c-73-243-2-10.hsd1.co.comcast.net) (Client Quit) |
| 2020-09-24 13:45:38 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-24 13:46:26 | → | ransom joins (~c4264035@c-73-243-2-10.hsd1.co.comcast.net) |
| 2020-09-24 13:48:11 | × | adamwespiser quits (~adam_wesp@209.6.42.110) (Ping timeout: 240 seconds) |
| 2020-09-24 13:48:34 | → | mirrorbird joins (~psutcliff@2a00:801:44a:a00b:20c3:c64:eb15:73a2) |
| 2020-09-24 13:50:37 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 264 seconds) |
| 2020-09-24 13:51:02 | × | Saukk quits (~Saukk@2001:998:dc:4a67:1c59:9bb5:b94c:4) (Remote host closed the connection) |
| 2020-09-24 13:51:28 | → | nbloomf joins (~nbloomf@2600:1700:83e0:1f40:fd4f:d033:4b52:6677) |
| 2020-09-24 13:52:03 | → | Nik05 joins (~Nik05@85.150.134.175) |
| 2020-09-24 13:52:26 | × | oish quits (~charlie@94.118.69.174) (Ping timeout: 272 seconds) |
| 2020-09-24 13:53:08 | → | shad0w_ joins (~shad0w_@160.202.37.157) |
| 2020-09-24 13:53:19 | <shad0w_> | hi all. |
| 2020-09-24 13:53:38 | <shad0w_> | i am currently learning about Functors on my haskell quest |
| 2020-09-24 13:53:57 | <shad0w_> | as an exercise, i need to write the Functor for the data type |
| 2020-09-24 13:54:01 | <shad0w_> | `data ITree a = Leaf (Int -> a) | Node [ITree a]` |
| 2020-09-24 13:54:15 | → | filwisher joins (~filwisher@cpc76738-dals23-2-0-cust186.20-2.cable.virginm.net) |
| 2020-09-24 13:54:46 | × | darjeeling_ quits (~darjeelin@122.245.123.72) (Ping timeout: 256 seconds) |
| 2020-09-24 13:54:51 | <shad0w_> | what i came up with was |
| 2020-09-24 13:54:54 | <shad0w_> | ` |
| 2020-09-24 13:54:57 | <shad0w_> | instance Functor ITree where |
| 2020-09-24 13:54:57 | <shad0w_> | fmap g (Leaf f) = Leaf (g . f) |
| 2020-09-24 13:54:57 | <shad0w_> | fmap _ (Node []) = Node [] |
| 2020-09-24 13:54:57 | <shad0w_> | fmap g (Node (x:xs)) = Node ([(fmap g x)] ++ [fmap g (Node xs)]) |
| 2020-09-24 13:54:58 | <shad0w_> | ` |
| 2020-09-24 13:54:58 | <[exa]> | shad0w_: please pastebin :] |
| 2020-09-24 13:55:15 | → | darjeeling_ joins (~darjeelin@122.245.123.72) |
| 2020-09-24 13:55:25 | <shad0w_> | alright |
| 2020-09-24 13:55:48 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-24 13:55:56 | <[exa]> | anyway when it's already here, it looks pretty much okay, the question is why would you create a new Node for fmapping again if you already have stripped the "wrap" once? |
| 2020-09-24 13:57:01 | <[exa]> | (hint: recursing manually is sometimes just confusing, if you want to do the same action all over some kind of list, just use `map`) |
| 2020-09-24 13:57:03 | <shad0w_> | https://paste.ofcode.org/dxSxd9D9zkSqj86AvE6uXF |
| 2020-09-24 13:57:14 | → | irc_user joins (uid423822@gateway/web/irccloud.com/x-kkhmlwcffthfhnqd) |
| 2020-09-24 13:57:34 | <shad0w_> | it wouldn't pass the typechecker any other way i tried. |
| 2020-09-24 13:58:02 | <shad0w_> | this passed the type check but had me a little confused if it does what i think it does |
| 2020-09-24 13:58:07 | <[exa]> | shad0w_: (about pastebins -- pasting more than ~2-3 lines to IRC is widely frowned upon, people here generally don't mind a lot but pastebinning is safer) |
| 2020-09-24 13:58:13 | × | Kaivo quits (~Kaivo@104-200-86-99.mc.derytele.com) (Ping timeout: 246 seconds) |
| 2020-09-24 13:58:50 | <shad0w_> | [exa]: i'll be mindfull of that, thanks. im new here. so my IRC ettiquites are a little (non-existant) lol |
| 2020-09-24 13:59:36 | <[exa]> | shad0w_: anyway, try giving the compiler this line (instd of both your variants for Node: |
| 2020-09-24 13:59:50 | <[exa]> | fmap g (Node a) = Node $ map _ a |
| 2020-09-24 14:00:25 | <[exa]> | the _ should produce a "nice" error that tells you what type you need to smash in there |
| 2020-09-24 14:00:49 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 264 seconds) |
| 2020-09-24 14:00:51 | → | Kaivo joins (~Kaivo@ec2-15-222-231-32.ca-central-1.compute.amazonaws.com) |
| 2020-09-24 14:01:45 | → | barzo joins (~hd@95.70.181.226) |
| 2020-09-24 14:02:06 | <shad0w_> | [exa]: it says found a hole: _ :: ITree a -> ITree b |
| 2020-09-24 14:02:28 | hackage | signable-haskell-protoc 0.2 - Deterministic serialisation and signatures with proto-lens support https://hackage.haskell.org/package/signable-haskell-protoc-0.2 (coingaming) |
| 2020-09-24 14:02:34 | <shad0w_> | that should just be an (fmap g) |
| 2020-09-24 14:02:55 | × | barzo quits (~hd@95.70.181.226) (Client Quit) |
| 2020-09-24 14:03:25 | → | Sgeo joins (~Sgeo@ool-18b982ad.dyn.optonline.net) |
| 2020-09-24 14:03:57 | hackage | signable 0.2 - Deterministic serialisation and signatures with proto-lens support https://hackage.haskell.org/package/signable-0.2 (coingaming) |
| 2020-09-24 14:04:21 | <shad0w_> | byorgey: that was a nice exercise. i needed to grind my brain gears on that one. |
| 2020-09-24 14:05:52 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-24 14:06:26 | <[exa]> | shad0w_: yeah, that should work :] |
| 2020-09-24 14:07:05 | <shad0w_> | [exa]: Thanks for the help : ) |
| 2020-09-24 14:07:26 | <[exa]> | shad0w_: anyway, you can look at the whole construction now as "getting through layers" -- you strip and re-do the Leaf and Node "tags", then you use whatever is needed to get into/modify the inner type |
| 2020-09-24 14:07:27 | × | kori quits (~kori@arrowheads/kori) (Read error: Connection reset by peer) |
| 2020-09-24 14:08:04 | <[exa]> | onion approach works quite well for this kind of exercises, and when you don't know, just leave a _ . |
| 2020-09-24 14:08:22 | → | tzh joins (~tzh@2601:448:c500:5300::82b3) |
| 2020-09-24 14:08:55 | <shad0w_> | getting fimiliar with the type signatures is what really helps me in the end |
| 2020-09-24 14:08:59 | → | kori joins (~kori@arrowheads/kori) |
| 2020-09-24 14:09:15 | <shad0w_> | okay i need to go from here -> here via this and this and then that |
| 2020-09-24 14:09:32 | <[exa]> | yeah there's a general approach to "just follow the types" |
| 2020-09-24 14:09:51 | <shad0w_> | but when a types get a little nested |
| 2020-09-24 14:10:04 | → | nineonine joins (~nineonine@216-19-190-182.dyn.novuscom.net) |
| 2020-09-24 14:10:05 | <shad0w_> | it gets hard to keep it in my brain all at once |
| 2020-09-24 14:10:10 | <shad0w_> | for now. |
| 2020-09-24 14:10:23 | <tdammers> | the great thing about typed languages is that you don't have to |
| 2020-09-24 14:10:27 | <shad0w_> | i think it's something you get the hang of as you progress ? |
| 2020-09-24 14:10:29 | → | howdoi joins (uid224@gateway/web/irccloud.com/x-pmfgngzmblrpwuzc) |
| 2020-09-24 14:10:30 | <tdammers> | (keep it all in your brain at once, that is) |
| 2020-09-24 14:10:40 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 260 seconds) |
| 2020-09-24 14:10:48 | <tdammers> | this is the real reason why people spell out types all the time even when the compiler could infer them |
| 2020-09-24 14:10:52 | <tdammers> | it's just easier on the brain |
| 2020-09-24 14:10:59 | <shad0w_> | i did a lot js in a previous life |
| 2020-09-24 14:11:04 | <shad0w_> | don't i know that lol |
| 2020-09-24 14:11:06 | <tdammers> | dump that information in the code so that the compiler can keep track for you |
| 2020-09-24 14:11:14 | → | adamwespiser joins (~adam_wesp@209.6.42.110) |
| 2020-09-24 14:11:15 | <[exa]> | helps a lot eg with writing monad instances and lenses for whatever |
| 2020-09-24 14:11:30 | <shad0w_> | i am yet to get to those |
| 2020-09-24 14:12:13 | <[exa]> | the second best thing on explicit types written everywhere is that the type errors don't escape |
| 2020-09-24 14:12:19 | × | adamwespiser quits (~adam_wesp@209.6.42.110) (Remote host closed the connection) |
| 2020-09-24 14:12:22 | <tdammers> | yup |
| 2020-09-24 14:12:28 | <[exa]> | but you need a larger program to truly appreciate that |
| 2020-09-24 14:13:02 | <tdammers> | yeah, if your code is still within the size limits of the average programmer brain, the benefit is marginal, but once you get past that point, it's super helpful |
| 2020-09-24 14:13:05 | <shad0w_> | tdammers: i did a exercism exercise in nim. the mentor reponse was, remove the conrete type from the function signature. the compiler can infer it anyway |
| 2020-09-24 14:13:15 | <shad0w_> | i was like:- no can do's ville, baby doll. |
| 2020-09-24 14:13:20 | <tdammers> | a bit like asserts on pre- and post-conditions in imperative code, just way more accurate |
All times are in UTC.