Logs: freenode/#haskell
| 2020-11-22 01:18:08 | → | conal joins (~conal@198.8.81.205) |
| 2020-11-22 01:19:22 | × | Tuplanolla quits (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi) (Quit: Leaving.) |
| 2020-11-22 01:22:51 | × | alp quits (~alp@2a01:e0a:58b:4920:1cfa:109c:d72:5dd) (Ping timeout: 272 seconds) |
| 2020-11-22 01:24:17 | → | Fractalis joins (~Fractalis@2601:987:280:8d40:eda9:f9e1:2072:cea7) |
| 2020-11-22 01:24:22 | × | _linker_ quits (~linker@185.12.21.77) (Remote host closed the connection) |
| 2020-11-22 01:31:42 | × | tmciver quits (~tmciver@cpe-172-101-40-226.maine.res.rr.com) (Read error: Connection reset by peer) |
| 2020-11-22 01:31:51 | → | justanotheruser joins (~justanoth@unaffiliated/justanotheruser) |
| 2020-11-22 01:33:46 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2020-11-22 01:34:56 | × | lucasb quits (uid333435@gateway/web/irccloud.com/x-ssbbedmexymeqbgx) (Quit: Connection closed for inactivity) |
| 2020-11-22 01:35:14 | → | Lord_of_Life_ joins (~Lord@46.217.221.152) |
| 2020-11-22 01:36:29 | × | Lord_of_Life quits (~Lord@unaffiliated/lord-of-life/x-0885362) (Ping timeout: 260 seconds) |
| 2020-11-22 01:39:23 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 265 seconds) |
| 2020-11-22 01:39:35 | → | wei2912 joins (~wei2912@unaffiliated/wei2912) |
| 2020-11-22 01:39:51 | × | conal quits (~conal@198.8.81.205) (Quit: Computer has gone to sleep.) |
| 2020-11-22 01:49:21 | × | DTZUZU quits (~DTZUZU@207.81.171.116) (Read error: Connection reset by peer) |
| 2020-11-22 01:50:56 | <conjunctive> | Hi, how do I go about building documentation for all of my dependencies with cabal? I've set Documentation to true for my global cabal config, but :doc still isn't working for third-party packages in GHCI. |
| 2020-11-22 01:51:31 | → | DTZUZU joins (~DTZUZU@207.81.171.116) |
| 2020-11-22 01:51:58 | × | da39a3ee5e6b4b0d quits (~da39a3ee5@2403:6200:8876:6c06:8500:38e7:4522:4d5) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-22 01:54:01 | → | redmp joins (~redmp@mobile-166-137-178-152.mycingular.net) |
| 2020-11-22 01:57:55 | × | olligobber quits (olligobber@gateway/vpn/privateinternetaccess/olligobber) (Remote host closed the connection) |
| 2020-11-22 02:03:33 | × | mupf quits (~micha@v22017094964653601.ultrasrv.de) (Ping timeout: 265 seconds) |
| 2020-11-22 02:05:57 | → | futuba joins (2fe3e53b@047-227-229-059.res.spectrum.com) |
| 2020-11-22 02:06:20 | <futuba> | Hi! I am doing CS194 exercise 2 here: https://www.seas.upenn.edu/~cis194/fall16/hw/08-functor-applicative.html |
| 2020-11-22 02:06:29 | <futuba> | Would somebody be able to walk me through how you would go through func2? |
| 2020-11-22 02:08:57 | × | xsperry quits (~as@unaffiliated/xsperry) (Remote host closed the connection) |
| 2020-11-22 02:10:05 | × | redmp quits (~redmp@mobile-166-137-178-152.mycingular.net) (Ping timeout: 260 seconds) |
| 2020-11-22 02:13:54 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2020-11-22 02:15:54 | × | jedai42 quits (~jedai@lfbn-dij-1-708-251.w90-100.abo.wanadoo.fr) (Ping timeout: 256 seconds) |
| 2020-11-22 02:19:18 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 256 seconds) |
| 2020-11-22 02:23:18 | × | avoandmayo quits (~textual@122-58-109-105-adsl.sparkbb.co.nz) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-22 02:26:49 | → | cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net) |
| 2020-11-22 02:30:23 | → | mupf joins (~micha@v22017094964653601.ultrasrv.de) |
| 2020-11-22 02:31:18 | × | sand_dull quits (~theuser@c-73-149-95-105.hsd1.ct.comcast.net) (Quit: Lost terminal) |
| 2020-11-22 02:31:59 | <koz_> | futuba: What do you mean by 'how would you go through func2'? |
| 2020-11-22 02:32:23 | <futuba> | to simplify it as an applicative or functor instance? |
| 2020-11-22 02:32:40 | <futuba> | the task is to take func2 xs = xs >>= (\x -> xs >>= \y -> return (x,y)), and rewrite it without monad bind |
| 2020-11-22 02:32:45 | <koz_> | futuba: That's tantamount to straight-up asking for an answer. |
| 2020-11-22 02:32:51 | <futuba> | i'm not sure how to approach it |
| 2020-11-22 02:33:03 | <koz_> | OK, so let's think about it this way. |
| 2020-11-22 02:33:03 | <futuba> | well the answer is here: https://www.seas.upenn.edu/~cis194/fall16/sols/08-functor-applicative.hs |
| 2020-11-22 02:33:11 | <futuba> | but i'm not sure how i would go about getting there |
| 2020-11-22 02:33:16 | <koz_> | Suppose instead of a (Monad f) constraint, you had (Functor f) |
| 2020-11-22 02:33:20 | <futuba> | right |
| 2020-11-22 02:33:29 | <koz_> | Now, this meand you've only got fmap to work with. |
| 2020-11-22 02:33:34 | <futuba> | yep |
| 2020-11-22 02:33:45 | <koz_> | And you have an 'f a', and you gotta get an 'f (a, a)'. |
| 2020-11-22 02:33:50 | <futuba> | yeah |
| 2020-11-22 02:33:55 | <koz_> | Now, the only thing you can use is fmap. |
| 2020-11-22 02:34:07 | <koz_> | So suppose we were to write 'func2 xs = fmap _ xs'. |
| 2020-11-22 02:34:11 | <koz_> | What type does the hole have? |
| 2020-11-22 02:35:23 | <futuba> | so fmap is a->b->(f a->f b) |
| 2020-11-22 02:35:35 | <futuba> | and func2 is f a -> f (a, a) |
| 2020-11-22 02:36:14 | <futuba> | is that possible? |
| 2020-11-22 02:36:24 | <koz_> | What do you mean? |
| 2020-11-22 02:36:38 | <futuba> | oh, i guess you can do a -> (a, a) |
| 2020-11-22 02:36:40 | <koz_> | You have 'func2 :: (Functor f) => f a -> f (a, a)' |
| 2020-11-22 02:36:48 | <koz_> | And we've got 'func2 xs = fmap _ xs'. |
| 2020-11-22 02:36:51 | <koz_> | What type is the hole? |
| 2020-11-22 02:36:57 | <futuba> | yeah, a->(a, a) should work |
| 2020-11-22 02:37:04 | <koz_> | OK, can you write such a function? |
| 2020-11-22 02:37:07 | × | xff0x quits (~fox@2001:1a81:53c2:b800:5bdf:9233:5c1b:206) (Ping timeout: 260 seconds) |
| 2020-11-22 02:37:13 | <futuba> | \x->(x, x) |
| 2020-11-22 02:37:28 | <koz_> | So that's the approach. |
| 2020-11-22 02:37:33 | <futuba> | but that's not correct |
| 2020-11-22 02:37:40 | <koz_> | Why not? |
| 2020-11-22 02:37:50 | <futuba> | func2 is not equivalent to fmap \x->(x, x) xs |
| 2020-11-22 02:37:59 | <futuba> | func1 is equivalent to that |
| 2020-11-22 02:38:28 | × | fimp quits (~fimp@217.151.98.168) (Remote host closed the connection) |
| 2020-11-22 02:38:30 | <futuba> | func2 [1,2] gives you [(1,1),(1,2),(2,1),(2,2)] |
| 2020-11-22 02:38:39 | → | xff0x joins (~fox@2001:1a81:53fc:6700:5177:b787:c6a7:ad81) |
| 2020-11-22 02:38:40 | <futuba> | it's right for the Just monad |
| 2020-11-22 02:38:43 | <futuba> | *Maybe |
| 2020-11-22 02:39:00 | <koz_> | So what does this tell you? |
| 2020-11-22 02:39:04 | <koz_> | Is Functor enough? |
| 2020-11-22 02:39:14 | <futuba> | no |
| 2020-11-22 02:39:27 | <koz_> | OK, so now let's try Applicative. This gives us two new tools to play with. |
| 2020-11-22 02:39:32 | <koz_> | Which are pure and <*>. |
| 2020-11-22 02:39:50 | <koz_> | And see if that gets you anyplace. |
| 2020-11-22 02:40:15 | <koz_> | There's not much I can do beyond saying 'consider your tools carefully and try things' which wouldn't just straight-up give you the answer. |
| 2020-11-22 02:40:45 | <futuba> | right, like when I read the answer i understood why it works, but i don't know how to get from that to the answer |
| 2020-11-22 02:41:07 | <koz_> | Yeah, which is why I'm telling you there's no magic formula. |
| 2020-11-22 02:41:15 | <futuba> | oh |
| 2020-11-22 02:41:18 | <koz_> | Do you see what func2 is doing in an abstract sense. |
| 2020-11-22 02:41:19 | <koz_> | ?* |
| 2020-11-22 02:41:19 | <lambdabot> | Maybe you meant: v @ ? . |
| 2020-11-22 02:41:43 | <koz_> | To make it easier, consider func2 specialized to Maybe. |
| 2020-11-22 02:41:50 | <futuba> | yeah, so I was trying that |
| 2020-11-22 02:41:53 | <koz_> | What's actually being done here? |
| 2020-11-22 02:41:58 | <futuba> | and func1 func2 and func3 were all identical |
| 2020-11-22 02:42:06 | <koz_> | Yeah, but that's in terms of _results_. |
| 2020-11-22 02:42:09 | <koz_> | I wasn't asking for that. |
| 2020-11-22 02:42:25 | <koz_> | They do very different things, it just so happens that they have the same result if f ~ Maybe. |
| 2020-11-22 02:42:33 | <futuba> | oh |
| 2020-11-22 02:42:34 | <monochrom> | No way func1, func2, func3 are the same. |
| 2020-11-22 02:43:25 | × | darjeeling_ quits (~darjeelin@122.245.219.209) (Ping timeout: 264 seconds) |
| 2020-11-22 02:43:33 | <futuba> | yeah, i guess i am having a little trouble understanding what func2 is doing abstractly |
| 2020-11-22 02:43:35 | → | cads joins (~cads@ip-64-72-99-232.lasvegas.net) |
| 2020-11-22 02:44:02 | <futuba> | it's like unwrapping it twice and then making a pair out of it kind of? |
| 2020-11-22 02:44:04 | <monochrom> | There is no need to stay abstract. Use f=[] to find out. |
| 2020-11-22 02:44:36 | <koz_> | (in fact, you already did, and your example of 'func2 [1,2]' holds all the answers you need) |
All times are in UTC.