Logs: liberachat/#haskell
| 2021-06-18 03:28:32 | <c_wraith> | Any of them |
| 2021-06-18 03:28:38 | <c_wraith> | The answer is the same for all of them |
| 2021-06-18 03:28:46 | <c_wraith> | "the question doesn't make sense" |
| 2021-06-18 03:29:09 | <qrpnxz> | ig a map from any value to "some string", or maybe a map from some arbitrary value to "some string" |
| 2021-06-18 03:29:45 | × | jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Client Quit) |
| 2021-06-18 03:29:50 | <qrpnxz> | or maybe a map from "some string" to any value, or maybe a map from "some string" to some arbitrary value |
| 2021-06-18 03:30:00 | <Axman6> | pure :: a -> Map k a; which k? |
| 2021-06-18 03:30:16 | <c_wraith> | Ok, so let's say import Data.Map (Map) and you evaluate (pure "some string" :: Map (IO String -> [Watermelon]) String) |
| 2021-06-18 03:30:43 | <c_wraith> | It type checks. |
| 2021-06-18 03:30:52 | <c_wraith> | Your definition of pure had better handle it correctly. |
| 2021-06-18 03:31:04 | <qrpnxz> | ok |
| 2021-06-18 03:32:03 | <c_wraith> | and to be clear: Map has a Functor instance, but not an Applicative instance. |
| 2021-06-18 03:32:22 | <qrpnxz> | i don't even see the functor instance in the library i found |
| 2021-06-18 03:32:49 | × | sheepduck quits (~sheepduck@cpe98524a8cef7c-cm98524a8cef7a.cpe.net.cable.rogers.com) (Ping timeout: 268 seconds) |
| 2021-06-18 03:32:50 | <c_wraith> | https://hackage.haskell.org/package/containers-0.6.4.1/docs/Data-Map-Lazy.html#t:Map |
| 2021-06-18 03:34:01 | <qrpnxz> | alright |
| 2021-06-18 03:34:21 | <c_wraith> | and the reason it's not Applicative is that pure makes no sense for it. see https://hackage.haskell.org/package/semigroupoids-5.3.5/docs/Data-Functor-Apply.html#t:Apply for instance |
| 2021-06-18 03:34:40 | × | Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 268 seconds) |
| 2021-06-18 03:34:49 | → | ddellacosta joins (~ddellacos@86.106.121.100) |
| 2021-06-18 03:34:59 | → | Lord_of_Life joins (~Lord@user/lord-of-life/x-2819915) |
| 2021-06-18 03:35:51 | × | machinedgod quits (~machinedg@135-23-192-217.cpe.pppoe.ca) (Ping timeout: 244 seconds) |
| 2021-06-18 03:36:23 | <qrpnxz> | or <*> made no sense |
| 2021-06-18 03:36:23 | → | jmcarthur joins (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) |
| 2021-06-18 03:36:38 | <c_wraith> | nah, <*> makes perfect sense, which was the point of my link to Apply there |
| 2021-06-18 03:36:45 | <c_wraith> | It has an instance for Map |
| 2021-06-18 03:37:03 | <qrpnxz> | isn't it the other way around |
| 2021-06-18 03:37:27 | <davean> | No, <*> is quite useful and makes sense for Map |
| 2021-06-18 03:37:32 | <c_wraith> | no, it's pretty easy to implement f <*> x for Map |
| 2021-06-18 03:37:35 | <davean> | but you couldn't impliment pure |
| 2021-06-18 03:37:41 | <qrpnxz> | i mean that map has an instance for apply |
| 2021-06-18 03:38:05 | <qrpnxz> | why couldn't you |
| 2021-06-18 03:38:18 | <c_wraith> | Eh. I don't really consider instances to belong to either types or classes more than the other |
| 2021-06-18 03:38:34 | <c_wraith> | a class can have instances for types, a type can have instances for classes |
| 2021-06-18 03:39:06 | × | ddellacosta quits (~ddellacos@86.106.121.100) (Ping timeout: 240 seconds) |
| 2021-06-18 03:39:15 | <qrpnxz> | can you show the difference, i've only ever seen one way |
| 2021-06-18 03:39:32 | <davean> | qrpnxz: what would "pure" be if your functor was a function? |
| 2021-06-18 03:39:56 | <c_wraith> | in ghci, type in ":info Show" and ":info []". either way, it lists a bunch of instances |
| 2021-06-18 03:40:22 | <qrpnxz> | davean, (const .) or smth like that ig |
| 2021-06-18 03:40:35 | <davean> | qrpnxz: think through that for even a second |
| 2021-06-18 03:40:39 | <davean> | ((->) Int) |
| 2021-06-18 03:41:00 | <davean> | Thats what you're trying to impliment pure for |
| 2021-06-18 03:41:09 | <davean> | fmap is obvious, its just (.) |
| 2021-06-18 03:41:19 | <qrpnxz> | you say that as if applicative for functions didn't exist |
| 2021-06-18 03:41:32 | <qrpnxz> | lol it's literally const haha |
| 2021-06-18 03:41:41 | <davean> | No, I say that to talk about how you're modeling functor in your head |
| 2021-06-18 03:41:42 | <c_wraith> | yeah, Map is not functions |
| 2021-06-18 03:42:09 | <qrpnxz> | ok, never said it was |
| 2021-06-18 03:42:42 | × | jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Ping timeout: 240 seconds) |
| 2021-06-18 03:42:45 | <qrpnxz> | thought their interface is the same now that you bring it up |
| 2021-06-18 03:43:09 | <c_wraith> | The big difference is that a function (k -> Maybe v) is negative in k, but (Map k v) is positive in k |
| 2021-06-18 03:43:18 | <davean> | c_wraith: right |
| 2021-06-18 03:43:29 | <qrpnxz> | what does negative in k mean |
| 2021-06-18 03:44:16 | <c_wraith> | it means it is a thing that only consumes values of type k. |
| 2021-06-18 03:44:41 | <qrpnxz> | and a map doesn't only take key's of k? |
| 2021-06-18 03:44:49 | <qrpnxz> | *keys |
| 2021-06-18 03:44:49 | <c_wraith> | no, toList exists |
| 2021-06-18 03:44:59 | <qrpnxz> | list is something else |
| 2021-06-18 03:45:09 | <c_wraith> | :t M.toList |
| 2021-06-18 03:45:10 | <lambdabot> | M.Map k a -> [(k, a)] |
| 2021-06-18 03:45:23 | <c_wraith> | as you can see, that *produces* values of type k |
| 2021-06-18 03:45:26 | <c_wraith> | not consumes them |
| 2021-06-18 03:46:11 | <qrpnxz> | ok, well (k -> a) -> [(k, a)] is not an invalid type, and i don't see what this has to do with pure |
| 2021-06-18 03:46:16 | <davean> | (->a) vs (a ->) |
| 2021-06-18 03:47:19 | <c_wraith> | it means for ((->) a), pure only needs to generate a value that consumes something of type a |
| 2021-06-18 03:47:35 | <c_wraith> | But for (Map k), pure needs to create something that can produce a value of type k |
| 2021-06-18 03:47:42 | <c_wraith> | and that's why it fails |
| 2021-06-18 03:48:27 | <qrpnxz> | i mean this is beside the point tbh. The reason i ask is that afaict in cat theory, a functor maps objects and morphism, fmap is only mapping morphisms, so it doesn't not seem to me that Functor is really a functor, and that's why i wonder either why it doesn't have pure or why it's called a functor, regardless of whether you think it's possible to have pure for Map or not (which if it doesn't i'd argue it |
| 2021-06-18 03:48:27 | <qrpnxz> | 's not a real functor) |
| 2021-06-18 03:49:30 | <qrpnxz> | i can easily create something that can produce a value of type k, just pick arbitrary key |
| 2021-06-18 03:49:52 | <c_wraith> | that would appear to be assuming the axiom of choice. :P |
| 2021-06-18 03:50:28 | <qrpnxz> | not arbitrary key on each call, just a set one |
| 2021-06-18 03:50:43 | <c_wraith> | But it would also violate the Applicative laws |
| 2021-06-18 03:50:50 | <qrpnxz> | how so |
| 2021-06-18 03:51:05 | <c_wraith> | pure id <*> x would not be equivalent to x |
| 2021-06-18 03:51:55 | <Axman6> | qrpnxz: if I ask you to create a Map Void a from pure with type a -> Map k a, how are you going to do it? |
| 2021-06-18 03:52:53 | <Axman6> | if I thern ask you to then make me a Map (b -> c) a using the same function, how do you do it? |
| 2021-06-18 03:53:03 | <qrpnxz> | idk enough about void, but can we at least pause this for a moment and address the underlying reason that i'm talking about this which is what i wrote in the above parapraph |
| 2021-06-18 03:53:51 | <c_wraith> | I don't think it's a separate issue |
| 2021-06-18 03:54:06 | <c_wraith> | You're considering a universe smaller than the haskell type system |
| 2021-06-18 03:54:14 | <monochrom> | In a typical "instance Functor MyParamaterizedType", MyParameterizedType is the object map. |
| 2021-06-18 03:54:42 | <qrpnxz> | i think it is because i don't actually care if map can have pure or not, it's whether functor in haskell is actually describing a functor, and if it is how it can do that without pure |
| 2021-06-18 03:54:53 | → | warnz joins (~warnz@2600:1700:77c0:5610:7144:467c:eae6:37e7) |
| 2021-06-18 03:55:12 | × | jacks- quits (~bc817c21@217.29.117.252) (Quit: http://www.okay.uz/) |
| 2021-06-18 03:55:27 | <c_wraith> | monochrom just answered that |
| 2021-06-18 03:55:30 | <monochrom> | The only two legit criticisms of Haskell's Functor class are "this is only an endo functor" and "this is hardcoded for one single category". |
| 2021-06-18 03:55:51 | <monochrom> | s/for/to/ |
| 2021-06-18 03:56:02 | <c_wraith> | both totally valid criticisms. |
| 2021-06-18 03:56:24 | <monochrom> | Right, but "this doesn't have an object map" is dumb. |
| 2021-06-18 03:56:28 | <qrpnxz> | i know that, but this is not the case for Map (it has no pure), so then it doesn't have the object map, therefore not a functor in reality |
| 2021-06-18 03:56:48 | → | yd502_ joins (~yd502@180.168.212.6) |
| 2021-06-18 03:57:05 | <Axman6> | it is definitely a functor though |
| 2021-06-18 03:57:07 | <c_wraith> | the object map is (Map k) |
| 2021-06-18 03:57:11 | <monochrom> | Wrong. Functoriality doesn't require pure. |
| 2021-06-18 03:57:26 | <c_wraith> | because the objects are types |
| 2021-06-18 03:57:29 | <qrpnxz> | if the object map is Map k then why is there no pure = Map k |
| 2021-06-18 03:57:33 | × | yd502 quits (~yd502@180.168.212.6) (Ping timeout: 244 seconds) |
| 2021-06-18 03:57:39 | <c_wraith> | because values and types are not the same |
| 2021-06-18 03:57:44 | <Axman6> | why do you think something needs pure to be a functor? functor is all about mapping morphisms |
| 2021-06-18 03:58:00 | <monochrom> | "data P a = MkP" is also a functor. |
| 2021-06-18 03:58:04 | <Axman6> | what is k? which one do you pick? |
All times are in UTC.