Newest at the top
2024-05-18 20:56:05 +0200 | y04nn | (~username@45.129.56.202) (Ping timeout: 240 seconds) |
2024-05-18 20:55:58 +0200 | <ski> | and in `(a -> Bool) -> Bool', `a' is again in positive position. if you have `test :: (T -> Bool) -> Bool', then this function `test' in some sense "contains" a number of `T' values (they're "output", although only indirectly, from the function `test'. you can only "prod" at them by providing predicate callbacks) |
2024-05-18 20:54:34 +0200 | <ski> | in `a -> Maybe b', `b' is in positive (output/result/covariant) position, while `a' is in negative (input/argument/parameter/contravariant) position |
2024-05-18 20:54:14 +0200 | <mauke> | ArrayStoreException |
2024-05-18 20:53:36 +0200 | <ski> | (think about rules like "positive times positive is positive", "positive times negative is negative", ..) |
2024-05-18 20:53:18 +0200 | <ski> | oh, also "positive (position)" for covariant, and "negative (position)" for contravariant |
2024-05-18 20:51:59 +0200 | <ski> | aryah : happy it made sense |
2024-05-18 20:51:37 +0200 | <ski> | there are various other words that are also used. covariant : order-preserving, increasing, monotone, upper. contravariant : order-reversing, decreasing, antitone, lower |
2024-05-18 20:51:06 +0200 | <aryah> | ski: ty, a very clear explanation, I wondered the same a few times |
2024-05-18 20:50:22 +0200 | <ski> | for methods (and functions in general), the inputs (arguments/parameters) are contravariant, and the output (result) is covariant |
2024-05-18 20:49:51 +0200 | <ski> | btw, if you have mutable arrays, then `U[]' is neither a subtype nor a supertype of `T[]', when `U' is a subtype of `T'. this is because we can both read (output) from arrays (which is covariant), and write (input) to arrays (which is contravariant). so saying `Bike[]' is a subtype of `Vehicle[]' is wrong, if the array is mutable |
2024-05-18 20:47:35 +0200 | <ski> | s/some kind/same kind/ |
2024-05-18 20:46:58 +0200 | <ski> | so, this is contravariant |
2024-05-18 20:46:31 +0200 | <ski> | a *supertype* `T', though, allowing `bar' in `D' to accept *more* types of objects than the original `bar' in `C' |
2024-05-18 20:46:25 +0200 | <ski> | however, if we instead look at argument/parameter types, say we have `void bar(U obj);' in `C', then we could have `void bar(T obj);' in `D'. because a `D' is supposed to be a `C' (you can pass a `D' object to where a `C' object is expected), `bar' in `D' will always have to be prepared for people sending `U's to it, we can't replace `U' with a subtype of `U', in the subclass `D'. we *can* replace `U' with |
2024-05-18 20:45:20 +0200 | <EvanR> | OOP. foo Blah blah |
2024-05-18 20:44:05 +0200 | <ski> | type `U' also has type `T'. this means that method return types are covariant |
2024-05-18 20:43:59 +0200 | <ski> | justsomeguy : some kind of thing comes up in Object-orientation, with subtyping. you can have a method (in a subclass) that possibly returns an object that's a subtype of the return type of the object in the superclass. so in superclass `C' you can have `T foo(Blah blah);', and in subclass `D', you can, if you want, instead have `U foo(Blah blah);' as long as `U' is a subtype of `T'. because every object of |
2024-05-18 20:40:54 +0200 | <ski> | justsomeguy : but for `ixmap', you provide `j -> i', getting back `Array i e -> Array j e', so here we're *reversing* direction ! hence, *contra*variant, in this case |
2024-05-18 20:40:09 +0200 | <ski> | justsomeguy : ditto for my `ximap', you provide `i -> j' and get back `Array i e -> Array j e', so both are going in the same direction, still |
2024-05-18 20:39:48 +0200 | <ncf> | in this case the functor under consideration is (`Array` e) |
2024-05-18 20:39:24 +0200 | <ski> | justsomeguy : for `fmap :: (a -> b) -> (Array i a -> Array i b)', we provide a function from `a' elements to `b' elements, and gets back a function from `a' arrays to `b' arrays .. so both functions, the element function, and the array function, go in the same direction |
2024-05-18 20:39:07 +0200 | <ncf> | as with functors: covariant is fmap :: (a -> b) -> f a -> f b, contravariant is contramap :: (a -> b) -> f b -> f a |
2024-05-18 20:38:27 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) |
2024-05-18 20:38:12 +0200 | <mauke> | ... |
2024-05-18 20:38:06 +0200 | <ski> | justsomeguy : covariant means "varies in the same direction", and contravariant means "varies in the opposite direction" |
2024-05-18 20:38:05 +0200 | euleritian | (~euleritia@dynamic-176-006-188-140.176.6.pool.telefonica.de) (Ping timeout: 240 seconds) |
2024-05-18 20:37:42 +0200 | <ski> | ncf : not sure |
2024-05-18 20:37:10 +0200 | <justsomeguy> | What do covariant and contravariant mean? |
2024-05-18 20:36:47 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) (Read error: Connection reset by peer) |
2024-05-18 20:36:47 +0200 | ski | . o O ( <https://en.wikipedia.org/wiki/Monoid_ring> ) |
2024-05-18 20:36:28 +0200 | <lambdabot> | array (-3,3) [(-3,18),(-2,8),(-1,2),(0,0),(1,2),(2,8),(3,18)] |
2024-05-18 20:36:26 +0200 | <ski> | > ixmap (-3,3) (^ 2) (L.tabulate (0,9) (\j -> 2*j)) -- not just subrange or selection, but also replication |
2024-05-18 20:33:56 +0200 | <ncf> | is this a Kan extension |
2024-05-18 20:33:01 +0200 | <ski> | covariant rather than contravariant, over map with finite support |
2024-05-18 20:32:16 +0200 | <ncf> | nice |
2024-05-18 20:31:40 +0200 | <lambdabot> | (Ix i, Ix j, Monoid e) => (j, j) -> (i -> j) -> Array i e -> Array j e |
2024-05-18 20:31:39 +0200 | <ncf> | :t ximap |
2024-05-18 20:31:19 +0200 | kaol_ | kaol |
2024-05-18 20:30:04 +0200 | sawilagar | (~sawilagar@user/sawilagar) (Ping timeout: 260 seconds) |
2024-05-18 20:29:30 +0200 | <lambdabot> | array (0,9) [(0,0),(1,2),(2,0),(3,0),(4,8),(5,0),(6,0),(7,0),(8,0),(9,18)] |
2024-05-18 20:29:29 +0200 | <ski> | > fmap getSum (ximap (0,9) (^ 2) (L.tabulate (-3,3) (\i -> Sum (i^2)))) |
2024-05-18 20:26:08 +0200 | <mauke> | ixmap can be used to give you a permutation of the input array |
2024-05-18 20:25:50 +0200 | destituion | (~destituio@2a02:2121:10b:62ca:10a5:f759:7fb5:9fb1) (Ping timeout: 256 seconds) |
2024-05-18 20:22:13 +0200 | <monochrom> | There is no dedicated subrange function, so yeah ixmap with id is one solution. But you can also try array (3,5) [ (i, a ! i) | i <- [3..5] ] |
2024-05-18 20:18:38 +0200 | <ncf> | doesn't look like a subrange to me |
2024-05-18 20:18:34 +0200 | <ncf> | <ncf> ixmap (1, 3) (subtract 1) a |
2024-05-18 20:17:27 +0200 | <justsomeguy> | So would I only use ixmap to get subranges of the input IArray? I don't see how else I could use it. I guess it depends on what type you chose as your index. |
2024-05-18 20:15:16 +0200 | <ncf> | (length wouldn't make sense for higher-dimensional arrays) |
2024-05-18 20:15:00 +0200 | <EvanR> | r[i] = a[f(i)] |