{"id":23651579,"url":"https://github.com/athanclark/frankenscript","last_synced_at":"2025-11-16T02:30:16.538Z","repository":{"id":23034666,"uuid":"26387503","full_name":"athanclark/frankenscript","owner":"athanclark","description":"JavaScript with Partial Application","archived":false,"fork":false,"pushed_at":"2014-11-11T21:43:59.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T16:38:26.993Z","etag":null,"topics":["javascript","terrible-idea"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athanclark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-09T06:20:59.000Z","updated_at":"2018-11-27T20:59:59.000Z","dependencies_parsed_at":"2022-08-21T18:10:33.539Z","dependency_job_id":null,"html_url":"https://github.com/athanclark/frankenscript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Ffrankenscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Ffrankenscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Ffrankenscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Ffrankenscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athanclark","download_url":"https://codeload.github.com/athanclark/frankenscript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239611990,"owners_count":19668272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","terrible-idea"],"created_at":"2024-12-28T16:38:31.047Z","updated_at":"2025-11-16T02:30:16.456Z","avatar_url":"https://github.com/athanclark.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"FrankenScript\n=============\n\n\u003e It's ALLLIIIIIVEEEEEEE!\n\nJust kidding, that would be cool, though.\n\n__Status__: _Experimental_\n\n--------\n\n## Introduction\nFrankenScript is a Partial Application utility for JavaScript.\n\n## Usage\n\nLet's dissect addition and turn it into a monstrosity. Here is an explicit\naddition function, `plus`:\n\n```javascript\nfunction plus(n,m) {\n  return n+m;\n}\n```\n\nVery standard. Now, in order to mutilate arbitrary functions and\nturn them into nightmares, we use `Uhgg`.\n\n```javascript\nvar frankenPlus = Ughh(plus);\n```\n...which is pronounced __groan__. `frankenPlus` can make for some pretty abbominable arithmetic! Watch in horror\nas we attach the dismembered parameters and get our desired solution:\n\n```javascript\nvar frankenPlus1 = frankenPlus(1);\n\nfrankenPlus1(2);\n➥ 3\n\nfrankenPlus1(3);\n➥ 4\n```\n\nNow that `frankenPlus` has the strength of a hundred functions, we can _really_ be a\nmad (computer) scientist! For instance, `zipWith`:\n\n```javascript\nvar set1 = [1,2,3,4,5];\nvar set2 = [1,2,3,4,5,6];\n\nzipWith(frankenPlus, set1, set2);\n➥ [ 2, 4, 6, 8, 10 ]\n```\nor, equivalently with [Underscore](http://underscorejs.org)'s map \u0026 element-wise application:\n\n```javascript\nvar plusN = _.map(set1, frankenPlus);\n\napp(plusN, set2);\n➥ [ 2, 4, 6, 8, 10 ]\n```\n\nBoth `zipWith` and `app` are taken from [Haskell](http://haskell.org).\n\n## Addons\n\n### Chunked Application\n[Lo-Dash](https://lodash.com/docs#curry) has a `curry` function that does something similar to\nthe partial application examples above, but it blends between JavaScript's multiple parameters \nand chained invocations. Now, I've included the same functionality so we can do fun stuffs like\nthis:\n\n```javascript\nvar plus4 = function (a,b,c,d){\n  return a+b+c+d;\n}\nvar frankenPlus4 = Ughh(plus4);\n\nfrankenPlus4(1)(2)(3)(4);\n➥ 10\n\nfrankenPlus4(1,2)(3,4);\n➥ 10\n\nfrankenPlus4(1)(2,3,4);\n➥ 10\n```\n\nI have an issue calling this `curry`, because JavaScript's native multi-parameter function application\n`(,)` is not a tuple or product functor - it's not even a value, however it might be unique.\nRegardless, you can't say it's the product functor _universally_, because it's not first-class. I'm going\nto try and make a proper `curry` / `uncurry` that respects the adjoint, but first I need a lambda\ncalculus.\n\n### Trivial Type Checking\nWe now have a very, very trivial method to declaring type signatures for your function. Observe:\n```javascript\nvar plusT = Ughh.typed(\"Number -\u003e Number -\u003e Number\", function (n,m) {return n+m});\n\nplusT;\n➥ { [Function: func] typeSig: 'Number -\u003e Number -\u003e Number' }\n\nplusT(1);\n➥ { [Function: func] typeSig: 'Number -\u003e Number' }\n\nplusT(1)(2);\n➥ 3\n\nplusT(1)(\"foo\");\n➥ [Error: Parameter(s) does not match type signature]\n```\n\n## TODO\n\n- Hindley-Milner parametric polymorphism type inference\n- Incremental (pseudo) type checking and signature declaration / binding\n- Fixpoint termination with explicit recursion\n- Lazy and Eager evaluation schemes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathanclark%2Ffrankenscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathanclark%2Ffrankenscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathanclark%2Ffrankenscript/lists"}