Logs: freenode/#haskell
| 2020-10-05 18:13:38 | × | zacts quits (~zacts@dragora/developer/zacts) (Quit: leaving) |
| 2020-10-05 18:15:49 | → | jiribenes joins (~jiribenes@rosa.jiribenes.com) |
| 2020-10-05 18:18:39 | → | bloodsta1ker joins (~bloodstal@46.166.187.154) |
| 2020-10-05 18:19:09 | → | idhugo joins (~idhugo@563472ae.rev.stofanet.dk) |
| 2020-10-05 18:19:53 | <ski> | zoom84 : do you understand it better, now ? |
| 2020-10-05 18:20:15 | <zoom84> | yeah. there are multiple aspects that confused me. with the correct sig I'm working through them one at a time |
| 2020-10-05 18:21:17 | <ski> | zoom84 : would you like to see how one could, manually, check the definition, given the type signature (continuing the line i started to get into, above) ? |
| 2020-10-05 18:21:27 | × | bloodstalker quits (~bloodstal@46.166.187.154) (Ping timeout: 258 seconds) |
| 2020-10-05 18:21:52 | <zoom84> | sure |
| 2020-10-05 18:22:27 | hackage | wai-extra 3.1.1 - Provides some basic WAI handlers and middleware. https://hackage.haskell.org/package/wai-extra-3.1.1 (MichaelSnoyman) |
| 2020-10-05 18:22:29 | <ski> | continuing from the incorrect type signature above (so you can see why it doesn't work), or using your current, correct, type signature ? |
| 2020-10-05 18:22:32 | → | chaosmasttter joins (~chaosmast@p200300c4a73b2e0100f3c5a701cd6e56.dip0.t-ipconnect.de) |
| 2020-10-05 18:22:43 | <zoom84> | let's use my correct sig. here's what I have: |
| 2020-10-05 18:22:43 | <ski> | (or both, if you want to) |
| 2020-10-05 18:22:50 | <zoom84> | fmap :: (a -> b) -> MyEither doodad a -> MyEither doodad b |
| 2020-10-05 18:22:54 | <ski> | ok |
| 2020-10-05 18:23:06 | <ski> | so, comparing that with |
| 2020-10-05 18:23:13 | → | Stanley00 joins (~stanley00@unaffiliated/stanley00) |
| 2020-10-05 18:23:23 | <ski> | fmap f (MyLeft x) = MyLeft x |
| 2020-10-05 18:23:24 | × | bloodsta1ker quits (~bloodstal@46.166.187.154) (Ping timeout: 256 seconds) |
| 2020-10-05 18:23:35 | → | bloodstalker joins (~bloodstal@46.166.187.178) |
| 2020-10-05 18:23:38 | <ski> | we can see that the formal parameters (the patterns) will get types |
| 2020-10-05 18:23:42 | <ski> | f :: a -> b |
| 2020-10-05 18:23:43 | <frdg> | is there a better way to turn a list into a set than using nub? |
| 2020-10-05 18:23:58 | <ski> | MyLeft x :: MyEither doodad a |
| 2020-10-05 18:24:10 | <Cale> | frdg: Data.Set.fromList |
| 2020-10-05 18:24:12 | <ski> | and that the result expression then ought to have the type |
| 2020-10-05 18:24:15 | → | takuan joins (~takuan@178-116-218-225.access.telenet.be) |
| 2020-10-05 18:24:24 | <ski> | MyLeft x :: MyEither doodad b |
| 2020-10-05 18:24:47 | → | albert_99 joins (~Albert@p200300e5ff0b5b425d211d042df94ce7.dip0.t-ipconnect.de) |
| 2020-10-05 18:24:48 | <Cale> | If you really want sets, might as well be using Data.Set -- it has more of the operations you probably want to perform on sets as well. |
| 2020-10-05 18:25:03 | <frdg> | Cale: I am trying to write that module myself. |
| 2020-10-05 18:25:24 | <ski> | zoom84 : so, the goal here is to take apart the formal parameters, the pattern, to get types for the variables in the pattern (here `f' and `x'), and then to check that the expected type for the result expression (sometimes called the "body" of the defining equation) is correct |
| 2020-10-05 18:25:35 | → | inkbottle joins (~inkbottle@aaubervilliers-654-1-101-245.w86-212.abo.wanadoo.fr) |
| 2020-10-05 18:25:43 | × | zebrag quits (~inkbottle@aaubervilliers-654-1-80-159.w86-212.abo.wanadoo.fr) (Ping timeout: 260 seconds) |
| 2020-10-05 18:25:49 | <frdg> | and I was going to use sets as lists that have been made sets. |
| 2020-10-05 18:25:58 | hackage | lists-flines 0.1.1.0 - Additional data and structures to some 'String'-related lists. https://hackage.haskell.org/package/lists-flines-0.1.1.0 (OleksandrZhabenko) |
| 2020-10-05 18:25:59 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-05 18:26:07 | <ski> | @type S.toList . S.fromList |
| 2020-10-05 18:26:09 | <lambdabot> | Ord a => [a] -> [a] |
| 2020-10-05 18:26:13 | <zoom84> | ski, I kinda stumbled on that route by just closely reading the compiler error messages and matching the expected vs actual types |
| 2020-10-05 18:26:30 | <Cale> | map head . group . sort -- this might also be of interest |
| 2020-10-05 18:26:44 | <zoom84> | that let me cobble together the correct signature...from which I was able to finally connect the dots |
| 2020-10-05 18:26:54 | <zoom84> | in terms of understanding all the params |
| 2020-10-05 18:26:54 | <frdg> | ok thanks |
| 2020-10-05 18:27:10 | <Cale> | > sort "mississippi" |
| 2020-10-05 18:27:12 | <lambdabot> | "iiiimppssss" |
| 2020-10-05 18:27:20 | <Cale> | > group . sort $ "mississippi" |
| 2020-10-05 18:27:22 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie) |
| 2020-10-05 18:27:22 | <lambdabot> | ["iiii","m","pp","ssss"] |
| 2020-10-05 18:27:26 | <Cale> | > map head . group . sort $ "mississippi" |
| 2020-10-05 18:27:29 | <lambdabot> | "imps" |
| 2020-10-05 18:27:35 | × | Stanley00 quits (~stanley00@unaffiliated/stanley00) (Ping timeout: 260 seconds) |
| 2020-10-05 18:27:36 | → | GyroW joins (~GyroW@ptr-48ujrfd1ztq5fjywfw3.18120a2.ip6.access.telenet.be) |
| 2020-10-05 18:27:36 | × | GyroW quits (~GyroW@ptr-48ujrfd1ztq5fjywfw3.18120a2.ip6.access.telenet.be) (Changing host) |
| 2020-10-05 18:27:36 | → | GyroW joins (~GyroW@unaffiliated/gyrow) |
| 2020-10-05 18:27:38 | <frdg> | I see. |
| 2020-10-05 18:27:44 | <ski> | zoom84 : ok. so we already know the type of `f'. but, given `MyLeft x :: MyEither doodad a', what will be the type of `x' ? |
| 2020-10-05 18:27:56 | × | brandly quits (~brandly@c-73-68-15-46.hsd1.ma.comcast.net) (Ping timeout: 256 seconds) |
| 2020-10-05 18:29:04 | <zoom84> | it will be 'b', correct? |
| 2020-10-05 18:29:08 | <ski> | no |
| 2020-10-05 18:29:25 | <zoom84> | it works as 'b' in my actual implementation |
| 2020-10-05 18:29:34 | <zoom84> | err |
| 2020-10-05 18:29:36 | <zoom84> | take that back |
| 2020-10-05 18:30:14 | <ski> | perhaps, if you ask in the interactor, it will have renamed some type variables. i'm talking specifically about the naming that we picked above, not about some other naming |
| 2020-10-05 18:30:15 | <zoom84> | MyLeft x works, which means it conforms to the return type sig of "MyEither doodad b" |
| 2020-10-05 18:30:26 | → | roconnor joins (~roconnor@host-45-78-194-116.dyn.295.ca) |
| 2020-10-05 18:30:39 | <ski> | fmap f (MyLeft x) = MyLeft x |
| 2020-10-05 18:30:44 | <zoom84> | yep |
| 2020-10-05 18:30:55 | <zoom84> | so you're asking what's the type of x? |
| 2020-10-05 18:30:56 | <ski> | note that i'm talking, so far, only about the underlined pattern (formal parameter) |
| 2020-10-05 18:30:59 | <ski> | yes |
| 2020-10-05 18:31:19 | <ski> | we know |
| 2020-10-05 18:31:21 | <ski> | MyLeft x :: MyEither doodad a |
| 2020-10-05 18:31:23 | <zoom84> | well,(MyLeft x) is a destructuring |
| 2020-10-05 18:31:29 | <ski> | so, we should be able to figure out |
| 2020-10-05 18:31:31 | <ski> | x :: ??? |
| 2020-10-05 18:31:45 | <ski> | yes, it's pattern-matching |
| 2020-10-05 18:31:55 | <zoom84> | and I'm passing a (MyLeft 10) in, as an example |
| 2020-10-05 18:32:06 | <zoom84> | such as fmap (*2) (MyLeft 10) |
| 2020-10-05 18:32:39 | <zoom84> | doodad is already bound by the partial application of My Either |
| 2020-10-05 18:32:44 | <zoom84> | so doesn't x have to be a? |
| 2020-10-05 18:32:55 | × | albert_99 quits (~Albert@p200300e5ff0b5b425d211d042df94ce7.dip0.t-ipconnect.de) (Ping timeout: 244 seconds) |
| 2020-10-05 18:32:57 | <ski> | no |
| 2020-10-05 18:32:59 | → | albert_91 joins (~Albert@p200300e5ff0b5b4248a33bded2872db1.dip0.t-ipconnect.de) |
| 2020-10-05 18:33:14 | <ski> | consider again your `data' type definition |
| 2020-10-05 18:33:24 | <ski> | data MyEither dog cat = MyLeft dog |
| 2020-10-05 18:33:25 | <ski> | | MyRight cat |
| 2020-10-05 18:33:28 | <ski> | deriving Show |
| 2020-10-05 18:33:30 | <zoom84> | you mean dog then? |
| 2020-10-05 18:34:30 | <ski> | the `MyLeft dog' part here is a "template", it actually means that if (e.g.) `t' has type `dog', then `MyLeft t' will have type `MyEither dog cat'. and if `u' has type `cat', then `MyRight u' will (also) get type `MyEither dog cat' |
| 2020-10-05 18:34:57 | <ski> | in your case, `dog' is `doodad', and `cat' is `a', since we're considering `MyLeft x :: MyEither doodad a' |
| 2020-10-05 18:35:06 | <ski> | and, instead of `t', you have `x' |
| 2020-10-05 18:35:55 | <zoom84> | so it's dog, correct |
| 2020-10-05 18:35:58 | <zoom84> | ? |
| 2020-10-05 18:36:01 | → | alp joins (~alp@2a01:e0a:58b:4920:84ce:b984:b792:c925) |
| 2020-10-05 18:36:05 | <ski> | if we rename `dog',`cat',`t',`u' to `doodad',`a',`x',`y', then the above becomes |
| 2020-10-05 18:36:46 | <ski> | the `MyLeft doodad' part here is a "template", it actually means that if (e.g.) `x' has type `doodad', then `MyLeft x' will have type `MyEither doodad a'. and if `y' has type `a', then `MyRight y' will (also) get type `MyEither doodad a' |
| 2020-10-05 18:37:18 | <ski> | in other words, if it helps, we're imagining now that we actually had written |
| 2020-10-05 18:37:33 | <ski> | data MyEither dogdad a = MyLeft doodad |
All times are in UTC.