{ "info": { "author": "UNKNOWN", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Programming Language :: Python :: Implementation :: CPython" ], "description": "miniadt\n========================================\n\nhow to use\n\n.. code:: \n\n ## create Type\n\n >>> from miniadt import ADTTypeProvider\n >>> TreeType = ADTTypeProvider(\"Tree\")\n\n >>> Node = TreeType(\"Node\", \"e children\")\n >>> Leaf = TreeType(\"Leaf\", \"e\")\n\n\n ## printing value\n\n >>> Leaf(e=10)\n Leaf(e=10)\n >>> Node(e=10, children=[Leaf(e=20)])\n Node(e=10, children=[Leaf(e=20)])\n\n\n ## use pattern match\n\n >>> @TreeType.match\n ... class depth(object):\n ... def Node(e, children):\n ... return max(depth(e)for e in children) + 1\n ...\n ... def Leaf(e):\n ... return 1\n\n >>> depth(Leaf(e=10))\n 1\n\n >>> depth(Node(e=10, children=[Leaf(e=20), Node(e=30, children=[Leaf(e=40)])]))\n 3\n\nminiadt has comprehensive check function.\n\n.. code::\n\n ## not comprehensive definition on pattern matching function error is occur \n\n ### 1. lack of dispatch andidates\n >>> class invalid_dispatch(object):\n ... def Node(e, children):\n ... return \"foo\"\n\n >>> TreeType.match(invalid_dispatch)\n Traceback (most recent call last):\n ...\n miniadt.NotComprehensive: Leaf is not found. expected=['Node', 'Leaf']\n\n\n ### 2. dispatch function's arguments are invalid.\n >>> class invalid_dispatch2(object):\n ... def Node(e): ## correct argsspec is \"e, children\"\n ... return \"foo\"\n ... def Leaf(e):\n ... return \"foo\"\n\n >>> TreeType.match(invalid_dispatch2)\n Traceback (most recent call last):\n ...\n miniadt.NotComprehensive: on Tree.Node: expected=['e', 'children'] != actual=['e']\n\n\nsimilar functions\n----------------------------------------\n\n- match\n- match_instance\n- classify\n\n.. code-block:: python\n\n from miniadt import ADTTypeProvider\n Tree = ADTTypeProvider(\"Tree\")\n Node = Tree(\"Node\", \"e children\")\n Leaf = Tree(\"Leaf\", \"e\")\n\n print(Leaf(e=10)) # => Leaf(e=10)\n print(Node(e=10, children=[Leaf(e=20)])) # => Node(e=10, children=[Leaf(e=20)])\n\n\n @Tree.match\n class depth(object):\n def Leaf(e):\n return 1\n\n def Node(e, children):\n return max(depth(e) for e in children) + 1\n\n\n print(depth(Leaf(e=10))) # => 10\n print(depth(Node(e=10, children=[Leaf(e=20)]))) # 2\n\n\n @Tree.match_instance\n class Applicator(object):\n def __init__(self, name):\n self.name = name\n\n def Leaf(self, e):\n return self.name\n\n def Node(self, e, children):\n return [self.name, [self(x) for x in children]]\n\n print(Applicator(\"foo\")(Leaf(e=10))) # => foo\n print(Applicator(\"foo\")(Node(e=10, children=[Leaf(e=20)]))) # => ['foo', ['foo']]\n\n\n @Tree.classify\n class ToDict(object):\n def Leaf(self, leaf):\n return leaf.e\n\n def Node(self, node):\n return {\"e\": node.e, \"children\": [self(e) for e in node.children]}\n\n todict = ToDict()\n print(todict(Leaf(e=10))) # => 10\n print(todict(Node(e=10, children=[Leaf(e=20)]))) # => {'e': 10, 'children': [20]}", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "miniadt", "package_url": "https://pypi.org/project/miniadt/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/miniadt/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/miniadt/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "tiny abstract data type on python", "version": "0.4.0" }, "last_serial": 1583321, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7730e172288b8fc87e0666c378075602", "sha256": "38867d48708c0f0dbc37590f2f9b980b44992b63d2f4f7ebbaa49c06618e8295" }, "downloads": -1, "filename": "miniadt-0.1.tar.gz", "has_sig": false, "md5_digest": "7730e172288b8fc87e0666c378075602", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4416, "upload_time": "2014-05-09T20:47:07", "url": "https://files.pythonhosted.org/packages/18/3d/b0c347061c15e39c0642dfc38b3b2e37f62433a3bebb538ed159f015c1b7/miniadt-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ffe97dc2952c036f5f3a735eee081739", "sha256": "734fe73d7e88646f76f9986c1a158da6c4cd9e75c46627cfde137bd9fd7e25a1" }, "downloads": -1, "filename": "miniadt-0.2.tar.gz", "has_sig": false, "md5_digest": "ffe97dc2952c036f5f3a735eee081739", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4371, "upload_time": "2014-05-09T20:54:45", "url": "https://files.pythonhosted.org/packages/eb/4c/907ceeffe7c801a1977d0ac775212d3a3ed41d881917469246deceac41ce/miniadt-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "2d1830532eda18b0f3a226b04d32fed7", "sha256": "bfaabf044d6d74bd8cd09a786bd40f7165a3d8449cb656551f585ed1306ef866" }, "downloads": -1, "filename": "miniadt-0.2.1.tar.gz", "has_sig": false, "md5_digest": "2d1830532eda18b0f3a226b04d32fed7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5159, "upload_time": "2014-05-25T14:54:59", "url": "https://files.pythonhosted.org/packages/4b/ef/76831e9f1392bb311e1af2ab38c0f6a4f596b7af13b4c89e0e04e73df36f/miniadt-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "4f850847ff5632676690c5dc399288cc", "sha256": "55059734183af89e597b22a4db26d2639c5e1b5c25990c330f8d5a4ba162bde0" }, "downloads": -1, "filename": "miniadt-0.3.0.tar.gz", "has_sig": false, "md5_digest": "4f850847ff5632676690c5dc399288cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6257, "upload_time": "2015-06-07T13:47:12", "url": "https://files.pythonhosted.org/packages/5e/f0/2b8975b2248c60a35460ee826291541ba5664966efc18687de1047c330b2/miniadt-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "550277f7b4052cdd5fcbfbb9736ff09c", "sha256": "ed46c1a676be64f33dd47797929938286236a40eff8f9dca095d6b7fb4ca4c48" }, "downloads": -1, "filename": "miniadt-0.4.0.tar.gz", "has_sig": false, "md5_digest": "550277f7b4052cdd5fcbfbb9736ff09c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5898, "upload_time": "2015-06-08T14:50:27", "url": "https://files.pythonhosted.org/packages/ec/a7/fe66caed24e82e4e01d7164aa99eec8db2f02dc16451df0ec736ecdc992b/miniadt-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "550277f7b4052cdd5fcbfbb9736ff09c", "sha256": "ed46c1a676be64f33dd47797929938286236a40eff8f9dca095d6b7fb4ca4c48" }, "downloads": -1, "filename": "miniadt-0.4.0.tar.gz", "has_sig": false, "md5_digest": "550277f7b4052cdd5fcbfbb9736ff09c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5898, "upload_time": "2015-06-08T14:50:27", "url": "https://files.pythonhosted.org/packages/ec/a7/fe66caed24e82e4e01d7164aa99eec8db2f02dc16451df0ec736ecdc992b/miniadt-0.4.0.tar.gz" } ] }