{"name":"sanctuary-show","version":"1.0.0","description":"Evaluable string representations","license":"MIT","repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"files":["/LICENSE","/README.md","/index.js","/package.json"],"dependencies":{},"devDependencies":{"sanctuary-scripts":"1.5.x"},"scripts":{"doctest":"sanctuary-doctest","lint":"sanctuary-lint","release":"sanctuary-release","test":"npm run lint && sanctuary-test && npm run doctest"},"gitHead":"46f523012a0ffcd26f24caebce148733fb9a48ee","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","_id":"sanctuary-show@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"dist":{"integrity":"sha512-63UqNGr5M6wkzKp6eGc/Gy6JBIV2PbzPd3q88+0F9z0qydAQsCWJ+7e4oor39rEEwj2GkZMDEhqGuiMl9eEnYw==","shasum":"72deb4812f9decec850e03286807dca1c97a1d61","tarball":"http://registry-npm.ywwl.com/sanctuary-show/download/sanctuary-show-1.0.0.tgz","fileCount":4,"unpackedSize":8109,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5fujCRA9TVsSAnZWagAALuUP+gNqTldTPm1m2cW/MVZ3\n0DAmVrrrA5+3BfN0nMGFxmKz6zewI079vWW5bATc+MFh0E2Sas5B8PwOfcCc\nTsPUOV+epFyG4W5hotRNN24RV1QEmS6DxOekjpo4Prr93diWG9hlbDCUIVxF\neA2ofzR3KflQm8p6TyybUolBJkMvo1RHX+Ta644HBV/SjFOqRlKq6pmmx7KQ\nC9kvut7KaHt1sD1ooqadtSAySkz0eKph2BWt+SU8vrm1MWHd+Qc1V2UA2pWn\nupF+qlNKl0nLwsB/0HKTPukyiH04F6Jan87Xgv5HE3saRdK7PYxxTubmRtus\nBs8K+z3z6BrhXvt4hCQsPF4pPhsHzncWYLExGHcjq416aJCJ0zNm9xdcDWIy\nHtp80y/bURXsOnL6fL+d9kOfhDYIPZDsF1A+bi7tuz6jKxBygMcT364S99l0\nh3/fRLD0ytfq85Snsk6WXFg88n4CKaP/zynQBe2V7tOnPCt29+V+quYnF4uz\nLtFwULKv17+niLwH1ru11jHwfRgqTqn4Yj4Ym3h1DbKEUUgujsqjKDjUiQbs\ny1VNf4d/StELBK3JC7O8yjf7zHk/sV3mk/HSzEghYgGFFy88OCC65YpNPedy\n0RtDD10J9C8qu5ecUHYiQUceCF0hb4xtuYxgj5nu0KFmQs1X2ldG0aQh+B3A\n78fT\r\n=kFpt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLNxg+Upd3UNF+f3EZ4MEy1DAgXazya0+i6ijvkFqjoQIgMu04D7ui/aE9vVUDeZlynorI1x1AJvyt1n9MVf8L02s="}],"size":2962,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-1.0.0.tgz"},"maintainers":[{"name":"davidchambers","email":"dc@davidchambers.me"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_1.0.0_1525021600824_0.7622912363000764"},"_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":1525021601200,"_cnpm_publish_time":1525021601200,"dist-tags":{"latest":"3.0.0"}}