Logs: freenode/#haskell
| 2020-11-13 14:10:26 | <royal_screwup21> | ski hmm yeah you're right |
| 2020-11-13 14:10:36 | <royal_screwup21> | it seems really weird |
| 2020-11-13 14:10:41 | <royal_screwup21> | the currrent impl |
| 2020-11-13 14:11:50 | <ski> | that `Show' instance would generate mostly readable output, getting relatively close to what your pretty-printing intended, while still generating a valid Haskell expression |
| 2020-11-13 14:12:17 | <royal_screwup21> | ski I'm not sure I understand what's wrong with wrt to precedence |
| 2020-11-13 14:12:26 | <ski> | of course, you can do your own pretty-printing as well (or instead), if you like. but please don't put that pretty-printing into `Show' |
| 2020-11-13 14:12:45 | <royal_screwup21> | so if the ziplist is [1, 2] 3 [5]. Then when I run "before", I should get "1" |
| 2020-11-13 14:12:58 | → | gproto0023 joins (~gproto23@unaffiliated/gproto23) |
| 2020-11-13 14:14:52 | <royal_screwup21> | that is, will it turn into [2] 1 [3,5] |
| 2020-11-13 14:15:25 | <ski> | `Show' instances are intended to work together with each other. if you declare an instance for a type, then it will automatically be combined with other existing instances, like for `Maybe',`[]',`Ratio',&c. whenever the user asks to show an input of a type combining your data type with these other types .. you have to consider how such interactions can look like. if you deviate from generating Haskell |
| 2020-11-13 14:15:32 | <ski> | expressions in `Show', then you will get weird mixes of Haskell and non-Haskell syntax, as a result of such combinations |
| 2020-11-13 14:15:42 | × | gproto023 quits (~gproto23@unaffiliated/gproto23) (Ping timeout: 265 seconds) |
| 2020-11-13 14:16:02 | <ski> | royal_screwup21 : "so if the ziplist is [1, 2] 3 [5]" -- what do you mean by this ? do you mean `ZL [1,2] 3 [5]', or do you mean `ZL [2,1] 3 [5]' ? |
| 2020-11-13 14:16:24 | <ski> | (it's not at all clear which you intended) |
| 2020-11-13 14:16:29 | <royal_screwup21> | the former |
| 2020-11-13 14:17:17 | <ski> | so, yes, `before (toZipList [2,1] 3 [5])' will return `toZipList [2] 1 [3,5]' |
| 2020-11-13 14:17:38 | × | bitmapper quits (uid464869@gateway/web/irccloud.com/x-pozlvwyabhwikscl) (Quit: Connection closed for inactivity) |
| 2020-11-13 14:17:45 | <ski> | iow, `before (ZL [1,2] 3 5)' will return `ZL [2] 1 [3,5]' -- this is the same thing |
| 2020-11-13 14:20:19 | <royal_screwup21> | ski the core idea behind this impl is that preprending an element to a list is inexpensive, whereas append is expensive -- am i thinking correctly? |
| 2020-11-13 14:21:41 | → | blankhart joins (~blankhart@pool-100-35-219-3.nwrknj.fios.verizon.net) |
| 2020-11-13 14:23:05 | × | Qui_Sum1 quits (~Qui_Sum@178.162.212.214) () |
| 2020-11-13 14:25:01 | <ski> | royal_screwup21 : yes, that's correct |
| 2020-11-13 14:25:06 | <royal_screwup21> | ok cool :) |
| 2020-11-13 14:25:15 | <royal_screwup21> | thanks for much for all your help - much appreciated |
| 2020-11-13 14:25:55 | × | bitmagie quits (~Thunderbi@200116b8068f010041b23aab865e3023.dip.versatel-1u1.de) (Quit: bitmagie) |
| 2020-11-13 14:26:52 | <ski> | "I'm not sure I understand what's wrong with wrt to precedence" -- hmm, not the best example, but consider `NotFocus (-3) % Focus 2', of type `Ratio (ZipElem Int)'. if you `show' this, you would presumably get `" -3 % (2)"', where that negation isn't protected by brackets, while precedence indicates that it ought to be |
| 2020-11-13 14:27:26 | → | bitmagie joins (~Thunderbi@200116b8068f010041b23aab865e3023.dip.versatel-1u1.de) |
| 2020-11-13 14:27:59 | <ski> | i'm sure you can construct better (that is, worse) examples, but i was trying to think of one that's in the base library |
| 2020-11-13 14:28:52 | × | neiluj quits (~jco@unaffiliated/neiluj) (Ping timeout: 256 seconds) |
| 2020-11-13 14:29:06 | <merijn> | ski: eh...did you use ZipList for a list zipper? That seems needlessly confusing, given the existing ZipList... |
| 2020-11-13 14:29:07 | × | bitmagie quits (~Thunderbi@200116b8068f010041b23aab865e3023.dip.versatel-1u1.de) (Client Quit) |
| 2020-11-13 14:29:18 | <ski> | the point is that `Show' is supposed to protect parts (like your `x' in `NotFocus x' and `Focus x') with wrapping brackets, if required to force the intended reading, due to precedence of operators |
| 2020-11-13 14:29:37 | <geekosaur> | merijn, royal_screwup21 did and was already told about the collision |
| 2020-11-13 14:29:41 | <merijn> | ah |
| 2020-11-13 14:29:49 | <ski> | merijn : "<dminuoso> royal_screwup21: btw, thats better called a zipper than a ziplist","<dminuoso> We have a newtype ZipList which provides an alternate Alternative instance for [], but it's unrelated to your thing" |
| 2020-11-13 14:31:43 | <ski> | royal_screwup21 : usually, except in very simple cases, when you're writing a `Show' instance manually, you should define `showsPrec', not `show' |
| 2020-11-13 14:33:17 | <ski> | you can define `show' if each possible value is "atomic", never requires wrapping brackets. e.g. `data Bool = False | True' has only "constant data constructors", none of them are parameterized, they don't take arguments, don't have components |
| 2020-11-13 14:36:04 | <ski> | royal_screwup21 : oh, and sorry. `showsChar' above should be `showChar' |
| 2020-11-13 14:36:28 | → | jamm_ joins (~jamm@unaffiliated/jamm) |
| 2020-11-13 14:36:31 | <royal_screwup21> | :) |
| 2020-11-13 14:38:18 | <ski> | sometimes it makes sense to not expose the implementation (in your case the `ZL' data constructor) in the `Show' instance. but then, imho, one ought to output an expression in terms of the exported operations, the public API, of the module (assuming the data type itself is exported) |
| 2020-11-13 14:38:32 | × | darjeeling_ quits (~darjeelin@122.245.210.116) (Ping timeout: 260 seconds) |
| 2020-11-13 14:38:52 | → | britva joins (~britva@2a02:aa13:7240:2980:bc4b:509a:98e6:5bb0) |
| 2020-11-13 14:38:58 | × | geekosaur quits (82659a09@host154-009.vpn.uakron.edu) (Remote host closed the connection) |
| 2020-11-13 14:39:07 | → | renzhi joins (~renzhi@2607:fa49:655f:e600::28da) |
| 2020-11-13 14:39:11 | <ski> | @let tabulate :: Ix i => (i,i) -> (i -> e) -> Array i e; tabulate ix f = listArray ix [f i | i <- range ix] |
| 2020-11-13 14:39:12 | <lambdabot> | Defined. |
| 2020-11-13 14:39:40 | <ski> | > tabulate (0,7) (\i -> i^2 + 1) |
| 2020-11-13 14:39:41 | <lambdabot> | error: |
| 2020-11-13 14:39:41 | <lambdabot> | Ambiguous occurrence ‘tabulate’ |
| 2020-11-13 14:39:41 | <lambdabot> | It could refer to |
| 2020-11-13 14:39:46 | <ski> | > L.tabulate (0,7) (\i -> i^2 + 1) |
| 2020-11-13 14:39:48 | <lambdabot> | array (0,7) [(0,1),(1,2),(2,5),(3,10),(4,17),(5,26),(6,37),(7,50)] |
| 2020-11-13 14:40:51 | <ski> | that's an example. `Array' is an abstract data type, so its `Show' instance displays an array value in terms of the `array' operation for constructing them (note that i called `listArray', now `array', above. `listArray' is another operation for constructing them) |
| 2020-11-13 14:40:55 | <ski> | @type array |
| 2020-11-13 14:40:57 | <lambdabot> | Ix i => (i, i) -> [(i, e)] -> Array i e |
| 2020-11-13 14:40:59 | <ski> | @type listArray |
| 2020-11-13 14:41:00 | <lambdabot> | Ix i => (i, i) -> [e] -> Array i e |
| 2020-11-13 14:42:02 | <ski> | (`listArray' assumes the elements come in a standard order. `array' doesn't assume that, you can list index-element pairs in any order) |
| 2020-11-13 14:42:13 | × | christo quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2020-11-13 14:45:19 | → | neiluj joins (~jco@43.245.204.77.rev.sfr.net) |
| 2020-11-13 14:47:05 | → | jakob_ joins (~textual@p200300f49f16220038ce51646f783e30.dip0.t-ipconnect.de) |
| 2020-11-13 14:47:53 | ← | jakalx parts (~jakalx@base.jakalx.net) ("Disconnected: closed") |
| 2020-11-13 14:49:40 | → | jakalx joins (~jakalx@base.jakalx.net) |
| 2020-11-13 14:50:08 | → | Amras joins (~Amras@unaffiliated/amras0000) |
| 2020-11-13 14:51:05 | → | darjeeling_ joins (~darjeelin@122.245.208.31) |
| 2020-11-13 14:51:24 | → | christo joins (~chris@81.96.113.213) |
| 2020-11-13 14:51:56 | → | Zetagon joins (~leo@c151-177-52-233.bredband.comhem.se) |
| 2020-11-13 14:52:06 | → | manjaro-user joins (~manjaro-u@109.77.71.163) |
| 2020-11-13 14:53:47 | → | motte joins (~weechat@unaffiliated/motte) |
| 2020-11-13 14:54:22 | × | jakalx quits (~jakalx@base.jakalx.net) (Ping timeout: 256 seconds) |
| 2020-11-13 14:54:36 | → | gproto023 joins (~gproto23@unaffiliated/gproto23) |
| 2020-11-13 14:56:29 | → | avdb joins (~avdb@ip-213-49-124-119.dsl.scarlet.be) |
| 2020-11-13 14:57:13 | × | gproto0023 quits (~gproto23@unaffiliated/gproto23) (Ping timeout: 264 seconds) |
| 2020-11-13 15:00:42 | <motte> | hi, how can i find all possible combinations of a nested list? the result should contain only one element from a given index |
| 2020-11-13 15:00:54 | → | lucasb joins (uid333435@gateway/web/irccloud.com/x-oypdzthrgbpglsbk) |
| 2020-11-13 15:01:09 | <motte> | e.g. [[1,2], [4,5]] should turn into [[1,2], [1,5], [2,4], [2,5]] |
| 2020-11-13 15:01:54 | <merijn> | > traverse sequence [[1,2], [4,5]] |
| 2020-11-13 15:01:56 | <lambdabot> | error: |
| 2020-11-13 15:01:56 | <lambdabot> | • Ambiguous type variables ‘f0’, |
| 2020-11-13 15:01:56 | <lambdabot> | ‘a0’ arising from a use of ‘show_M31303913069... |
| 2020-11-13 15:01:59 | <merijn> | aww |
| 2020-11-13 15:02:26 | × | xff0x quits (~fox@2001:1a81:53f2:4b00:f0ff:5175:9775:725d) (Ping timeout: 264 seconds) |
| 2020-11-13 15:03:52 | <xerox_> | > sequence [[1,2],[4,5]] |
| 2020-11-13 15:03:54 | <lambdabot> | [[1,4],[1,5],[2,4],[2,5]] |
| 2020-11-13 15:04:05 | <merijn> | rats, it *is* just sequence? |
| 2020-11-13 15:04:18 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-11-13 15:04:35 | <motte> | oh i messed it up, the result should be [[1,4], [1,5], [2,4], [2,5]] |
| 2020-11-13 15:04:40 | <xerox_> | ding! |
| 2020-11-13 15:05:24 | <merijn> | xerox_: I thought that first, but thought the type didn't match >.> |
| 2020-11-13 15:06:25 | × | acarrico quits (~acarrico@dhcp-68-142-39-249.greenmountainaccess.net) (Ping timeout: 240 seconds) |
| 2020-11-13 15:07:24 | × | FreeBirdLjj quits (~freebirdl@101.228.42.108) () |
| 2020-11-13 15:07:33 | → | conal joins (~conal@66.115.157.159) |
| 2020-11-13 15:08:28 | <motte> | huh it really is sequence |
| 2020-11-13 15:08:56 | → | bitmapper joins (uid464869@gateway/web/irccloud.com/x-vehblmdtqrevxqug) |
| 2020-11-13 15:09:13 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 264 seconds) |
| 2020-11-13 15:09:22 | <bqv> | well what d'you know, it really is just sequence |
| 2020-11-13 15:09:27 | → | mtothem joins (~mtothem@h-213-180.A392.priv.bahnhof.se) |
| 2020-11-13 15:09:29 | × | kritzefitz quits (~kritzefit@fw-front.credativ.com) (Remote host closed the connection) |
| 2020-11-13 15:09:44 | ← | jsmolic parts (~quassel@95.168.121.30) ("https://quassel-irc.org - Chat comfortably. Anywhere.") |
All times are in UTC.