{"id":24394403,"url":"https://github.com/ad-si/haskram","last_synced_at":"2026-05-21T03:02:19.801Z","repository":{"id":272212264,"uuid":"912311345","full_name":"ad-si/Haskram","owner":"ad-si","description":"Wolfram Language / Mathematica clone written in Haskell. Fork of github.com/mrtwistor/mmaclone","archived":false,"fork":false,"pushed_at":"2025-05-11T18:34:01.000Z","size":1309,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T12:36:20.387Z","etag":null,"topics":["cas","haskell","mathematica","wolfram","wolfram-language"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ad-si.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-05T07:51:20.000Z","updated_at":"2025-05-21T08:21:52.000Z","dependencies_parsed_at":"2025-01-13T01:19:15.218Z","dependency_job_id":null,"html_url":"https://github.com/ad-si/Haskram","commit_stats":null,"previous_names":["ad-si/haskram"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ad-si/Haskram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad-si%2FHaskram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad-si%2FHaskram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad-si%2FHaskram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad-si%2FHaskram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ad-si","download_url":"https://codeload.github.com/ad-si/Haskram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad-si%2FHaskram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33286664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cas","haskell","mathematica","wolfram","wolfram-language"],"created_at":"2025-01-19T19:24:14.507Z","updated_at":"2026-05-21T03:02:19.772Z","avatar_url":"https://github.com/ad-si.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Haskram\n\nA simple term rewriting system\nwith [Wolfram Language](https://www.wolfram.com/language/)'s syntax.\n\n![haskram](./demo.png)\n\n\n## Usage\n\n```sh\ngit clone https://github.com/ad-si/Haskram\ncd Haskram\nmake install\n```\n\nPrebulid binary files are available on the\n[release page](https://github.com/ad-si/Haskram/releases).\n\n\n## Features\n\nThis interpreter is intended to mimic every exact detail of `Wolfram Language`,\nincluding but not limited to its syntax, semantic,\nexpression structure, evaluation details, etc.\n(All the scripts below were executed in the REPL session of the `haskram` program)\n\n1. The program support nearly all `Wolfram Language`'s syntax sugar,\n  infix operators as well as their precedence.\n  E.g., inequality expression chain\n  is parsed to the same AST with `Wolfram Language`.\n\n  ```wolfram\n  In[1]:= FullForm[a==b\u003e=c\u003c=d\u003ce]\n  Out[1]= Inequality[a,Equal,b,GreaterEqual,c,LessEqual,d]\n  ```\n\n  Some more complicated examples:\n\n  ```wolfram\n  In[2]:= FullForm[P@1@2//3]\n  Out[2]= 3[P[1[2]]]\n  In[3]:= FullForm[P''''[x]]\n  Out[3]= Derivative[4][P][x]\n  In[4]:= FullForm[Hold[(1 ##\u0026)[2]]]\n  Out[4]= Hold[Function[Times[1,SlotSequence[1]]][2]]\n  ```\n\n2. `Wolfram Language`'s powerful pattern matching is also implemented.\n\n  ```wolfram\n  (*The famous bubble sort implementation*)\n  In[1]:= sortRule := {x___,y_,z_,k___}/;y\u003ez -\u003e {x,z,y,k}\n  In[2]:= {64, 44, 71, 48, 96, 47, 59, 71, 73, 51, 67, 50, 26, 49, 49}//.sortRule\n  Out[2]= {26,44,47,48,49,49,50,51,59,64,67,71,71,73,96}\n  (*Symbolic manipulation*)\n  In[3]:= rules:={Log[x_ y_]:\u003eLog[x]+Log[y],Log[x_^k_]:\u003ek Log[x]}\n  In[4]:= Log[a (b c^d)^e] //. rules\n  Out[4]= Log[a]+e (Log[b]+d Log[c])\n  ```\n\n  Currently, the derivative function `D` is not built-in supported,\n  but you could easily implement one\n  with the powerful pattern matching facilities.\n\n  ```wolfram\n  In[5]:= D[a_,x_]:=0\n  In[6]:= D[x_,x_]:=1\n  In[7]:= D[a_+b__,x_]:=D[a,x]+D[Plus[b],x]\n  In[8]:= D[a_ b__,x_]:=D[a,x] b+a D[Times[b],x]\n  In[9]:= D[a_^(b_), x_]:= a^b(D[b,x] Log[a]+D[a,x]/a b)\n  In[10]:= D[Log[a_], x_]:= D[a, x]/a\n  In[11]:= D[Sin[a_], x_]:= D[a,x] Cos[a]\n  In[12]:= D[Cos[a_], x_]:=-D[a,x] Sin[a]\n  (*performing derivative*)\n  In[13]:= D[Sin[x]/x,x]\n  Out[13]= -x^(-2) Sin[x]+Cos[x] x^(-1)\n  In[14]:= D[%,x]\n  Out[14]= -Cos[x] x^(-2)-(-2 x^(-3) Sin[x]+Cos[x] x^(-2))-x^(-1) Sin[x]\n  ```\n\n  Pattern test facility is of the same semantic with `Wolfram Language`'s.\n\n  ```wolfram\n  In[15]:= {{1,1},{0,0},{0,2}}/.{x_,x_}/;x+x==2 -\u003e a\n  Out[15]= {a,{0,0},{0,2}}\n  In[16]:= {a, b, c, d, a, b, b, b} /. a | b -\u003e x\n  Out[16]= {x,x,c,d,x,x,x,x}\n  In[17]:= g[a_*b__]:=g[a]+g[Times[b]]\n  In[18]:= g[x y z k l]\n  Out[18]= g[k]+g[l]+g[x]+g[y]+g[z]\n  In[19]:= q[i_,j_]:=q[i,j]=q[i-1,j]+q[i,j-1];q[i_,j_]/;i\u003c0||j\u003c0=0;q[0,0]=1;Null\n  In[20]:= q[5,5]\n  Out[20]= 252\n  ```\n\n3. Some more interesting scripts\n\n  ```wolfram\n  In[1]:= ((#+##\u0026) @@#\u0026) /@{{1,2},{2,2,2},{3,4}}\n  Out[1]= {4,8,10}\n  In[2]:= fib[n_]:=fib[n]=fib[n-1]+fib[n-2];fib[1]=fib[2]=1;Null\n  In[3]:= fib[100]\n  Out[3]= 354224848179261915075\n  In[4]:= fib[1000000000000]\n  Iteration Limit exceeded, try to increase $IterationLimit\n  In[5]:= Print/@fib/@{10,100}\n  55\n  354224848179261915075\n  Out[5]= {Null,Null}\n  ```\n\nFor more information please refer to the project\n[wiki](https://github.com/ad-si/Haskram/wiki).\n\n\n## TODOs\n\nSome serious design errors are exposed during development,\nwhich I consider are inhibiting the project from scaling up.\nSo currently the primary focus will be on refactoring\nrather than adding new features/functions.\n\n- [ ] More mathematical functions (`Sin`, `Cos`, `Mod` etc...)\n- [ ] Arbitrary precision floating arithmetic using GMP\n    (GNU Multiple Precision Arithmetic Library),\n    currently arbitrary integer, double and rational number are supported.\n- [ ] More built-in functions (`Level`, `Import`, `Derivative`etc...)\n- [x] More sophisticated pattern matching\n  - [x] head specification (of the form Blank[*Head*]),\n      currently it only support list type\n  - [x] Pattern Test\n  - [x] BlankSequence, BlankNullSequence\n  - [ ] Other pattern matching expression, like `Verbatim`, `Longest`\n- [x] RecursionLimit\n- [ ] Negative index e.g. in `Part`\n- [ ] Negative level specification\n- [ ] Curried function e.g. `f[a][b]`\n    (currently it will throw an error if one is trying to attach value\n    to the curried form through `Set` or `SetDelayed`)\n- [ ] Use iPython as front end\n- [x] Replace String implementation with more efficient Text\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad-si%2Fhaskram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fad-si%2Fhaskram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad-si%2Fhaskram/lists"}