{"name":"sanctuary-show","version":"2.0.0","description":"Evaluable string representations","license":"MIT","repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"dependencies":{},"devDependencies":{"sanctuary-scripts":"4.0.x"},"scripts":{"doctest":"sanctuary-doctest","lint":"sanctuary-lint","release":"sanctuary-release","test":"npm run lint && sanctuary-test && npm run doctest"},"gitHead":"3761b5f2cdc20ce1134575a702282575dda59d5d","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","_id":"sanctuary-show@2.0.0","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-REj4ZiioUXnDLj6EpJ9HcYDIEGaEexmB9Fg5o6InZR9f0x5PfnnC21QeU9SZ9E7G8zXSZPNjy8VRUK4safbesw==","shasum":"2326b4744f4b0f993f18ca56a29f68a50f514637","tarball":"http://registry-npm.ywwl.com/sanctuary-show/download/sanctuary-show-2.0.0.tgz","fileCount":4,"unpackedSize":8624,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeIcwFCRA9TVsSAnZWagAAAtMP/jTY8h4WO9eIcvbmEIU0\nKWlofzn/nOsW4o9tJWWbajBHfsZbfGhXDg9cW1F/bTOQITH8yim1hjZ1c4Em\nHQP2jLxBkZJJM9Xdh5Uw4J7hVqzfIGgaBq8olXOKaWoKnXQJb8rO9hay1+/2\nEygygB5L2AnrQy6e3YYGii3VN6jpHLHa2Ksaj5B8/Mq5frEZr5AyGkWUn/wE\n6iOCTTiabyqUBOATGoiYkuP2t1+ibN5JZONqYfTplszrSvV1KVtXeyb6LJW1\nIb4d5nQOl2U3mtRW65j/diHhv/p9+AADaYxvbAA2HffGIX04qdRocQYSGEpd\nUhkVq4XjxqAJrUAUZNtP237xItDapNq0RxbVw7WaOT5xBqpwgeQTbrXgXn5w\nrUO0lHP4yUf/s6eLkwDMv9FgPVSYiZ5kgLUdbI1S4u6OHl9PW/22+LuxUhv1\n7C7EINnLtKr7d1CoriqGswoaOjbq4ajVLXzi8JoUR4V71rV5ThmmqbdiY7XH\nED42h/BUuQTZTpQOZYuvvdwmq+q9m7EjfgavAbTgUEaSPqdEkk0nhQBLJj7m\ngO22g4QeVzW/x2mdCb+7wgifIfCVf9jammgzagdL9CtnSWAzMynbJ5q8kqMA\nbKY6xQsvUA33iPwvpnPdWQ/OxoogyvEnnGIJTQJOJcZ0sLmBeAeMeA7898Ty\n356R\r\n=Nen9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMVrx+VisKj7yHiXwR0ZjwzxOBZxp1ySirD0oiJ26WlAIgduEdRLUCwTOgMEX6DiTtNCqQWflsHoG4uk8rZGbNiKw="}],"size":3018,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-2.0.0.tgz"},"maintainers":[{"name":"davidchambers","email":"dc@davidchambers.me"}],"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_2.0.0_1579273220899_0.6555976519375721"},"_hasShrinkwrap":false,"readme":"# sanctuary-show\n\nHaskell has a `show` function which can be applied to a compatible value to\nproduce a descriptive string representation of that value. The idea is that\nthe string representation should, if possible, be an expression which would\nproduce the original value if evaluated.\n\nThis library provides a similar [`show`](#show) function.\n\nIn general, this property should hold: `eval (show (x)) = x`. In some cases\nparens are necessary to ensure correct interpretation (`{}`, for example,\nis an empty block rather than an empty object in some contexts). Thus the\nproperty is more accurately stated `eval ('(' + show (x) + ')') = x`.\n\nOne can make values of a custom type compatible with [`show`](#show) by\ndefining a `@@show` method. For example:\n\n```javascript\n//# Maybe#@@show :: Maybe a ~> () -> String\n//.\n//. ```javascript\n//. > show (Nothing)\n//. 'Nothing'\n//.\n//. > show (Just (['foo', 'bar', 'baz']))\n//. 'Just ([\"foo\", \"bar\", \"baz\"])'\n//. ```\nMaybe.prototype['@@show'] = function() {\n  return this.isNothing ? 'Nothing' : 'Just (' + show (this.value) + ')';\n};\n```\n\n### <a name=\"show\" href=\"https://github.com/sanctuary-js/sanctuary-show/blob/v3.0.0/index.js#L62\">`show :: Showable a => a -⁠> String`</a>\n\nReturns a useful string representation of the given value.\n\nDispatches to the value's `@@show` method if present.\n\nWhere practical, `show (eval ('(' + show (x) + ')')) = show (x)`.\n\n```javascript\n> show (null)\n'null'\n\n> show (undefined)\n'undefined'\n\n> show (true)\n'true'\n\n> show (new Boolean (false))\n'new Boolean (false)'\n\n> show (-0)\n'-0'\n\n> show (NaN)\n'NaN'\n\n> show (new Number (Infinity))\n'new Number (Infinity)'\n\n> show ('foo\\n\"bar\"\\nbaz\\n')\n'\"foo\\\\n\\\\\"bar\\\\\"\\\\nbaz\\\\n\"'\n\n> show (new String (''))\n'new String (\"\")'\n\n> show (['foo', 'bar', 'baz'])\n'[\"foo\", \"bar\", \"baz\"]'\n\n> show ([[[[[0]]]]])\n'[[[[[0]]]]]'\n\n> show ({x: [1, 2], y: [3, 4], z: [5, 6]})\n'{\"x\": [1, 2], \"y\": [3, 4], \"z\": [5, 6]}'\n```\n","publish_time":1579273221014,"_cnpm_publish_time":1579273221014,"dist-tags":{"latest":"3.0.0"}}