Logs: freenode/#haskell
| 2020-10-05 17:42:37 | → | klardotsh joins (~klardotsh@c-71-231-242-112.hsd1.wa.comcast.net) |
| 2020-10-05 17:42:48 | <ski> | at top of your source file : |
| 2020-10-05 17:42:50 | <ski> | {-# LANGUAGE InstanceSigs #-} |
| 2020-10-05 17:42:53 | <ski> | later : |
| 2020-10-05 17:42:58 | <ski> | data MyEither dog cat = MyLeft dog |
| 2020-10-05 17:43:02 | <ski> | | MyRight cat |
| 2020-10-05 17:43:06 | <ski> | deriving Show |
| 2020-10-05 17:43:12 | <ski> | |
| 2020-10-05 17:43:15 | <ski> | instance Functor (MyEither doodad) |
| 2020-10-05 17:43:16 | <zoom84> | sorry ski, missed that. it's hard to follow multiple threads of help at once. i'll at it |
| 2020-10-05 17:43:23 | <ski> | where |
| 2020-10-05 17:43:28 | <ski> | fmap :: (a -> b) -> (MyEither doodad foobar -> MyEither a b) |
| 2020-10-05 17:43:32 | <ski> | fmap f (MyLeft x) = MyLeft x |
| 2020-10-05 17:43:36 | <ski> | fmap f (MyRight y) = MyRight (f y) |
| 2020-10-05 17:43:45 | <ski> | zoom84 : like that ^ |
| 2020-10-05 17:44:21 | <ski> | zoom84 : "fmap is in a library source file. you're saying i should put it there?" -- yes, there is a general type signature of `fmap' in the type class declaration of `Functor', it looks like |
| 2020-10-05 17:44:25 | <ski> | class Functor f |
| 2020-10-05 17:44:27 | <ski> | where |
| 2020-10-05 17:44:33 | <ski> | fmap :: (a -> b) -> (f a -> f b) |
| 2020-10-05 17:45:22 | <ski> | however, when making an `instance' declaration, you can actually (if you enable the `InstanceSigs' language extension, as above) put the specific type signatures, for your instance, on the type class methods |
| 2020-10-05 17:45:35 | × | tessier quits (~treed@kernel-panic/copilotco) (Ping timeout: 260 seconds) |
| 2020-10-05 17:46:03 | × | ym555 quits (~ym@41.42.210.219) (Ping timeout: 260 seconds) |
| 2020-10-05 17:46:26 | <ski> | geekosaur : pretty sure they have relevant indentation in their source code :) |
| 2020-10-05 17:46:55 | × | snakemasterflex quits (~snakemast@213.100.206.23) (Ping timeout: 240 seconds) |
| 2020-10-05 17:46:58 | <geekosaur> | I'm not, because you get that error instead of "turn on InstanceSigs" if you didn't indent it. |
| 2020-10-05 17:47:31 | <geekosaur> | and you don't get other errors you might think you would, it'd just be a local redeclaration which is legal |
| 2020-10-05 17:47:52 | <ski> | ah, i missed that. perhaps they dedented, then, since from earlier discussion, it seemed the issue wasn't some error, but understanding the code in question |
| 2020-10-05 17:47:57 | <geekosaur> | until you go to use it and it complains it's declared twice in the same scope, one in Prelude |
| 2020-10-05 17:48:24 | × | vicfred quits (~vicfred@unaffiliated/vicfred) (Quit: Leaving) |
| 2020-10-05 17:48:31 | <ski> | zoom84 : yes, make sure the definition (and type signature) of `fmap' is actually indented more than the `instance Functor ..' line |
| 2020-10-05 17:48:47 | <zoom84> | indent was ok. here's what I get: |
| 2020-10-05 17:49:03 | <zoom84> | instance Functor (MyEither doodad) where |
| 2020-10-05 17:49:09 | <zoom84> | fmap :: (a -> b) -> MyEither doodad foobar -> MyEither a b |
| 2020-10-05 17:49:29 | <zoom84> | fmap f (MyRight x) = MyRight (f x) |
| 2020-10-05 17:49:42 | <zoom84> | fmap f (MyLeft x) = MyLeft x |
| 2020-10-05 17:49:43 | → | mirrorbird joins (~psutcliff@2a00:801:2d5:9d73:ff00:6553:d451:a276) |
| 2020-10-05 17:49:50 | <zoom84> | • Couldn't match type ‘a’ with ‘doodad’ ‘a’ is a rigid type variable bound by the type signature for: fmap :: forall a b foobar. (a -> b) -> MyEither doodad foobar -> MyEither a b |
| 2020-10-05 17:50:09 | <zoom84> | that error is for the fmap f (MyLeft x) = MyLeft x line |
| 2020-10-05 17:50:10 | <ski> | zoom84 : is there actually some (more) spaces in front of those last three lines you showed, in your source code ? |
| 2020-10-05 17:50:24 | <zoom84> | spaces. don't know how to retain intent pasting into this web irc client |
| 2020-10-05 17:50:30 | <ski> | zoom84 : yes, you get that error because your type signature is wrong (as mentioned before) |
| 2020-10-05 17:50:44 | <ski> | it's ok, as long as they're there, in your code |
| 2020-10-05 17:50:55 | × | albert_99 quits (~Albert@p200300e5ff0b5b425d211d042df94ce7.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-10-05 17:51:04 | → | thir joins (~thir@p200300f27f0fc60038c1b16891cbfa03.dip0.t-ipconnect.de) |
| 2020-10-05 17:51:06 | <zoom84> | missed the correction in the cross-talk. what's the correct sig |
| 2020-10-05 17:51:16 | × | Guest_57 quits (590fec7f@x590fec7f.dyn.telefonica.de) (Remote host closed the connection) |
| 2020-10-05 17:51:26 | <ski> | the point, i thought, was that you wanted to figure out the correct signature yourself ? |
| 2020-10-05 17:51:40 | → | conal joins (~conal@64.71.133.70) |
| 2020-10-05 17:51:56 | <zoom84> | i do |
| 2020-10-05 17:52:04 | <zoom84> | why is the sig I wrote incorret |
| 2020-10-05 17:52:23 | <zoom84> | ie, what's the correct sig |
| 2020-10-05 17:52:29 | → | nievlo joins (bd801243@189.128.18.67) |
| 2020-10-05 17:52:38 | → | tessier joins (~treed@kernel-panic/copilotco) |
| 2020-10-05 17:52:48 | × | geekosaur quits (42d52102@66.213.33.2) (Remote host closed the connection) |
| 2020-10-05 17:52:57 | <ski> | if you look at `fmap :: (a -> b) -> MyEither doodad foobar -> MyEither a b', and compare it with the definition equation `fmap f (MyLeft x) = MyLeft x', you can see that the first parameter,`f', gets type `a -> b', and the second parameter, `MyLeft x', gets type `MyEither doodat foobar', and that the result `MyLeft x' is to have type `MyEither a b' |
| 2020-10-05 17:53:34 | <ski> | zoom84 : do you understand that part, matching up parameters and result, in a definition equation like `fmap f (MyLeft x) = MyLeft x', with the corresponding parameter types and result type, in the type signature ? |
| 2020-10-05 17:53:54 | ← | nievlo parts (bd801243@189.128.18.67) () |
| 2020-10-05 17:55:30 | → | bloodstalker joins (~bloodstal@46.166.187.154) |
| 2020-10-05 17:55:32 | × | thir quits (~thir@p200300f27f0fc60038c1b16891cbfa03.dip0.t-ipconnect.de) (Ping timeout: 260 seconds) |
| 2020-10-05 17:56:20 | → | shatriff joins (~vitaliish@217.27.153.240) |
| 2020-10-05 17:57:16 | <zoom84> | still working on it... |
| 2020-10-05 17:57:29 | <ski> | zoom84 : a "yes" or "no" would be nice |
| 2020-10-05 17:57:31 | <zoom84> | understand what you wrote ski...making changes to understand |
| 2020-10-05 17:57:35 | <ski> | ok |
| 2020-10-05 17:58:05 | × | alx741_ quits (~alx741@186.178.110.22) (Ping timeout: 240 seconds) |
| 2020-10-05 17:58:20 | <zoom84> | zoom, I understand. in isolation it makes sense, ie for simpler functions. in this context I get confused |
| 2020-10-05 17:58:33 | <ski> | next step, it to actually check that the matching up of formal parameters (aka patterns) and result (expression), with the parameter and result types, actually makes sense |
| 2020-10-05 17:58:48 | <ski> | so, let's think about that |
| 2020-10-05 17:58:53 | <ski> | we know |
| 2020-10-05 17:58:55 | <zoom84> | give me a sec.. |
| 2020-10-05 17:59:05 | <ski> | fmap :: (a -> b) -> MyEither doodad foobar -> MyEither a b |
| 2020-10-05 17:59:06 | <zoom84> | can only work on one thought experiemnt at a time |
| 2020-10-05 17:59:07 | <ski> | fmap f (MyLeft x) = MyLeft x |
| 2020-10-05 17:59:32 | <ski> | and, from matching up parameters and result with corresponding types in signature, we get |
| 2020-10-05 17:59:35 | <ski> | f :: a -> b |
| 2020-10-05 17:59:42 | <ski> | MyLeft x :: MyEither doodad foobar |
| 2020-10-05 17:59:48 | <ski> | MyLeft x :: MyEither a b |
| 2020-10-05 18:00:02 | × | Usurp quits (~Usurp@217.146.82.202) () |
| 2020-10-05 18:00:22 | × | is_null quits (~jpic@pdpc/supporter/professional/is-null) (Ping timeout: 244 seconds) |
| 2020-10-05 18:00:45 | × | oisdk quits (~oisdk@2001:bb6:3329:d100:2471:1ee3:650d:c8f7) (Quit: oisdk) |
| 2020-10-05 18:00:54 | <ski> | (that's the same as i mentioned before, just spelled out a little more explicitly, using the `::' ("has type") notation) |
| 2020-10-05 18:01:08 | ski | waits for zoom84 |
| 2020-10-05 18:01:42 | × | dyeplexer quits (~lol@unaffiliated/terpin) (Read error: Connection reset by peer) |
| 2020-10-05 18:02:01 | <monochrom> | I wonder if it's helpful again to do my trick. By going "instance Functor (MyEither doodad)", you saying: in "(a -> b) -> f a -> f b" you're setting "f" to "MyEither doodad". So do that consistently and see what you get. |
| 2020-10-05 18:02:26 | → | mananamenos joins (~mananamen@84.122.202.215.dyn.user.ono.com) |
| 2020-10-05 18:04:34 | ← | cohn parts (~noone@unaffiliated/cohn) () |
| 2020-10-05 18:06:03 | × | mananamenos_ quits (~mananamen@vpn236-17.vpns.upv.es) (Ping timeout: 260 seconds) |
| 2020-10-05 18:06:21 | → | justsomeguy joins (~justsomeg@unaffiliated/--/x-3805311) |
| 2020-10-05 18:06:29 | <zoom84> | :r |
| 2020-10-05 18:07:00 | <ski> | Ok, one module loaded. |
| 2020-10-05 18:07:19 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2020-10-05 18:09:46 | <zoom84> | finally have a signature that correctly compiles...reading over to understand fully. |
| 2020-10-05 18:09:48 | × | bitmapper quits (uid464869@gateway/web/irccloud.com/x-umfptdbczzisdhag) (Quit: Connection closed for inactivity) |
| 2020-10-05 18:09:50 | × | mirrorbird quits (~psutcliff@2a00:801:2d5:9d73:ff00:6553:d451:a276) (Quit: Leaving) |
| 2020-10-05 18:09:55 | <ski> | ok |
| 2020-10-05 18:10:28 | → | cohn joins (~noone@unaffiliated/cohn) |
| 2020-10-05 18:10:55 | × | mananamenos quits (~mananamen@84.122.202.215.dyn.user.ono.com) (Ping timeout: 240 seconds) |
| 2020-10-05 18:11:28 | → | mananamenos joins (~mananamen@84.122.202.215.dyn.user.ono.com) |
| 2020-10-05 18:11:51 | → | vicfred joins (~vicfred@unaffiliated/vicfred) |
| 2020-10-05 18:13:21 | × | jiribenes quits (~jiribenes@rosa.jiribenes.com) (Read error: Connection reset by peer) |
All times are in UTC.