Skip to content
Permalink
Browse files

Did a bunch of things the last few days, committing just to get back

to normal.

Git should really at least attempt cluster commits automatically so
you don't need to do it manually...something to work on for Magic Word
:)
  • Loading branch information...
xkapastel committed Feb 28, 2019
1 parent 0548ad8 commit f3b675c2859f10a271b279d33ac965ba86869ef1
@@ -1,94 +1,16 @@
# Magic Word
A Forth-based FaaS platform. Typed, purely functional concatenative
code for scripting the web โ€” and others! With deep learning! ๐Ÿš€
A programming system focused on functions and machine learning.

## Table of contents
- [About](#about)
- [Getting Started](#getting-started)
- [ABC](#abc)
- [Inference](#inference)
- [Architecture](#architecture)
- [Roadmap](#roadmap)
- [Documentation](#documentation)
- [License](#license)

## About
Magic Word is a function-as-a-service (FaaS) platform where users
collaboratively write code that executes in a server-side container.

My vision for Magic Word is something similar to
[Glitch](https://glitch.com/) and [IFTTT](https://ifttt.com/): a way
for small groups of developers to collaborate on a running program,
with an emphasis on integration with web services and generation of
audiovisual content.

## Getting Started
`dotnet run --project ./src/MagicWord.Web/MagicWord.Web.fsproj` will
(eventually) start the web service.

## ABC
Magic Word uses a minimalist, purely functional dialect of Forth known
as *ABC*.

```
[A] [B] a = B [A]
[A] [B] b = [[A] b]
[A] c = [A] [A]
[A] d =
[A] s B r = [B] A
/foo symbols, the use/mention distinction for words
#foo tags, identity functions with unobservable effects
!foo bangs, side effects using linear capabilities
```

I'm hoping that Forth's word-at-a-time model will lend itself well to
formal manipulation by program synthesizers, and in particular neural
language models. I view this as a similar argument to Lisp lending
itself well to manipulation by macros due to its simplistic syntax.

### Inference
I'm interested in [deep
inference](http://alessio.guglielmi.name/res/cos/) and hope to combine
this with [illative
logic](https://www.semanticscholar.org/paper/Systems-of-Illative-Combinatory-Logic-Complete-for-Barendregt-Bunder/f3093a1cec21b03d03f99aca549b74aab8a4e545)
as a way to build ad-hoc type systems, with support for features like
typeclasses and more. I'll also mention [computability
logic](http://www.csc.villanova.edu/~japaridz/CL/), but I still need
to think about applications of this.

## Architecture
`MagicWord.Lang` implements ABC. `MagicWord.Web` is a web server. The
idea is that routes like `/words/foo` will show the execution of the
word named `foo`.

There will probably be additional things like IRC and Twitter clients
as well.

## Roadmap
I'd like to use Magic Word to explore a number of experimental ideas
in programming languages and machine learning:

### Programming on a mobile device
Smartphones have been around for many years now but they're still not
good environments for writing code. I have some ideas about this that
I'd like to try out, in particular: programming on a mobile device
should not feel like "writing code", it should feel more like googling
for a function. Consider [SmartSynth: Synthesizing Smartphone
Automation Scripts from Natural
Language](https://www.microsoft.com/en-us/research/publication/smartsynth-synthesizing-smartphone-automation-scripts-natural-language/).

### Recreate results from [Neural Program Synthesis with Priority Queue Training](https://arxiv.org/abs/1801.03526)

Character and word based neural language models achieve good results
and are now commonplace. The word-at-a-time model seems to be a
natural fit for Forth, and I'd like to generate Forth code with these
techniques.

### Recreate graphics/audio programming model from [IBNIZ](http://pelulamu.net/ibniz/)
I like the idea of interpreting a function as a map from time to
sample intensity, or a map from 2D space to color space; these seem
like really simple audio/graphics APIs that can rival e.g. Processing
for functional code.
## Documentation
Documentation created with mdBook is available on [GitHub
Pages](https://xkapastel.github.io/magic-word).

## License
Magic Word is available under the terms of the GNU Affero General
@@ -0,0 +1,228 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Arithmetic Types - Magic Word</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="The Magic Word manual">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />

<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print">

<!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">

<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css">
<link rel="stylesheet" href="tomorrow-night.css">
<link rel="stylesheet" href="ayu-highlight.css">

<!-- Custom theme stylesheets -->



</head>
<body class="light">
<!-- Provide site root to javascript -->
<script type="text/javascript">var path_to_root = "";</script>

<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>

<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = 'light'; }
document.body.className = theme;
document.querySelector('html').className = theme + ' js';
</script>

<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<ol class="chapter"><li class="affix"><a href="introduction.html">Introduction</a></li><li class="affix"><a href="program-rewriting.html">Program Rewriting</a></li><li class="affix"><a href="arithmetic-types.html" class="active">Arithmetic Types</a></li><li class="affix"><a href="open-deduction.html">Open Deduction</a></li><li class="affix"><a href="transactors.html">Transactors</a></li><li class="affix"><a href="neural-language-models.html">Neural Language Models</a></li></ol>
</nav>

<div id="page-wrapper" class="page-wrapper">

<div class="page">

<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light <span class="default">(default)</span></button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>

<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>

</div>

<h1 class="menu-title">Magic Word</h1>

<div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>


<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>


<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>

<div id="content" class="content">
<main>
<p>When creating a programming language, the question arises of what
things should be <em>primitive</em> and what things should be defined in
terms of those primitives. I think a good way to tackle this problem
is by appeal to the things that are primitive in the surrounding
intellectual context.</p>
<p>Consider the basic algebraic rules for addition:</p>
<pre><code>(a + (b + c)) = ((a + b) + c) associativity
a + b = b + a commutativity
a + 0 = a identity
</code></pre>
<p>These rules say that whenever you have an expression on one side of an
equals sign, you're allowed to transform it in to the expression on
the other side. &quot;Transform&quot; sounds a lot like what functions do, so
let's rewrite those rules using <code>&lt;-&gt;</code> to mean a pair of functions that
go from left to right and right to left:</p>
<pre><code> assocl: (a + (b + c)) &lt;-&gt; ((a + b) + c) :assocr
commute: (a + b) &lt;-&gt; (b + a) :commute
zeroi: a &lt;-&gt; (a + 0) :zeroe
</code></pre>
<p>These are functions that operate on <em>sum types</em>, types of the form
<code>a + b</code>. What is a sum type? In keeping with the arithmetic analogy,
think of the expression as representing the <em>number of values in that
type</em>. If the type <code>a</code> has <code>a</code> values, and the type <code>b</code> has <code>b</code>
values, then the type <code>a + b</code> has <code>a + b</code> values.</p>
<p>In light of this argument, it's interesting to look at the languages
that do <em>not</em> have sum types: C, C++, D, Go, JavaScript, Python, Ruby,
Perl, PHP, Tcl. If no popular languages have sum types, does that mean
they are not primitive? Or does it mean most popular languages have
failed at identifying a good set of primitives?</p>

</main>

<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->

<a rel="prev" href="program-rewriting.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>



<a rel="next" href="open-deduction.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>


<div style="clear: both"></div>
</nav>
</div>
</div>

<nav class="nav-wide-wrapper" aria-label="Page navigation">

<a href="program-rewriting.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>



<a href="open-deduction.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>

</nav>

</div>








<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script>


<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script>

<!-- Custom JS scripts -->




</body>
</html>
@@ -72,7 +72,7 @@
</script>

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<ol class="chapter"><li class="affix"><a href="introduction.html">Introduction</a></li><li class="affix"><a href="extensibility.html">Extensibility</a></li><li class="affix"><a href="search.html">Search</a></li><li class="affix"><a href="abc.html">ABC</a></li></ol>
<ol class="chapter"><li class="affix"><a href="introduction.html">Introduction</a></li><li class="affix"><a href="program-rewriting.html">Program Rewriting</a></li><li class="affix"><a href="arithmetic-types.html">Arithmetic Types</a></li><li class="affix"><a href="open-deduction.html">Open Deduction</a></li><li class="affix"><a href="transactors.html">Transactors</a></li><li class="affix"><a href="neural-language-models.html">Neural Language Models</a></li></ol>
</nav>

<div id="page-wrapper" class="page-wrapper">
@@ -136,15 +136,21 @@ <h1 class="menu-title">Magic Word</h1>

<div id="content" class="content">
<main>
<p><a href="language-and-spaces.html">Language &amp; Spaces</a> argues for search as an
alternative to the &quot;writing&quot; metaphor for creating software. It also
discusses modern approaches to program synthesis, and in particular
neural language models.</p>
<p><a href="abc.html">ABC</a> describes the purely functional bytecode used throughout
Magic Word and adapted from the <a href="https://github.com/dmbarbour/wikilon">Awelon
project</a>, introduces sum,
product and exponential types in analogy to arithmetic, and describes
an approach to effects based on continuous transactions.</p>
<p>Magic Word is a hobbyist research &amp; development project in programming
languages and machine learning. I would like to experiment with a
number of recent developments, including:</p>
<ul>
<li>combinatory term rewriting for mobile code</li>
<li><a href="http://okmij.org/ftp/continuations/">delimited continuations</a> for program structure</li>
<li>neural language models for program synthesis</li>
</ul>
<p>The organization of the documentation is as follows:</p>
<p><a href="program-rewriting.html">Program Rewriting</a>
<a href="arithmetic-types.html">Arithmetic Types</a>
<a href="delimited-continuations.html">Delimited Continuations</a>
<a href="open-deduction.html">Open Deduction</a>
<a href="transactors.html">Transactors</a>
<a href="neural-language-models.html">Neural Language Models</a></p>

</main>

Oops, something went wrong.

0 comments on commit f3b675c

Please sign in to comment.
You canโ€™t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.