Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Consider a Core term
In the interaction net encoding compiler path, assuming EAL-typability, we would encode this (if of form
In the bespoke encoding path, we instead create a new node type
Furthermore, we can safely encode non-EAL-typable terms this way, such as the Ackermann function, and they can safely interact with the rest of the interaction net (which must have been an EAL-typable term, treating the bespoke-encoded subterm as opaque).
The decision of whether or not to take the bespoke path can be made for all subterms of this form according to some heuristic (or possibly exact cost calculation) in the compiler.
In terms of deciding on what functions should be bespoke, analysis should be done at the front end language, producing core terms which have syntactic marks.
I suggest the syntactic marks be quasiquote (`) and comma (,).
Lisps have used this for quite some time, variations include
Further thoughts on bespoke encoding of non-primitive types:
More generally, with our Core term
I think this works - it follows all the interaction net laws and should preserve semantics - but there are oddities:
I'm not sure it will make sense in practice - perhaps for some small functions? In general, though, we have no idea of the size (and corresponding read-back cost) of
Currently as of the merging of pull request #94, we can bespoke primitive types:
This works over a type called
Functions are written as such
plus ∷ Primitive → Primitive → Maybe Primitive plus (PInt i1) (PInt i2) = Just (PInt $ i1 + i2) plus (PBool _) _ = Nothing plus _ (PBool _) = Nothing
Currently the return type is a maybe, however this is not needed as when we compile Core, type errors should not occur at this level. Doing it this way allows us to make hand made BOHM INets and for it somewhat gracefully handle type errors (can be made more graceful, if Maybe is returned after every argument).
What needs to be fleshed out, is the Core -> Primitive bespoke translation.
Augmenting the parser of Bohm, so custom infix operators can have proper precedence and to remove all hard-coded functions such as +.