Created
August 6, 2014 22:19
-
-
Save dominictarr/edd33980582bdaf5c424 to your computer and use it in GitHub Desktop.
git's secure datastructure described by a schema thingee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//top level is types, key:values are the structure that object must have, | |
//and the types of the values. | |
//Link means the hash of an object of the named type. | |
//Plus and Star define sets. And are just like regular expression + and * | |
//you could also have ? (Maybe) but it's not necessary to describe git. | |
{ | |
COMMIT: { | |
//a cypherlink to a commit object | |
//(Plus means 1 or more) | |
parent: Plus(Link("COMMIT")), | |
//a single line string (primitive) | |
author: /[^\n], | |
// an positive integer (primitive) | |
timestamp: Timestamp, | |
//an arbitary string | |
message: String, | |
// a link to | |
tree: Link("TREE")} | |
TREE: { | |
//Star means 0 or more of the following structure. | |
files: Star({ | |
//9 bit number | |
mode: Number(0, 512), | |
// an arbitary string | |
filename: String, | |
//either the string 'dir' or the string 'file' | |
type: Or("dir", "file"), | |
//link to the file snapshot | |
content: Or(Link('TREE'), Link('BLOB')) | |
} | |
//an blob is just an arbitary buffer | |
BLOB: Buffer | |
} |
Hmm i really like the idea of creating a trivial language that specifies these data structures. Maybe this could be Go dsl, or capnp.
also:
jbenet> domanic on schemas and types, why can't you have a link called "type" that points to the schema? (imo it doesn't need to be special, the base ipfs merkle dag already gives you this)
03:26 ← lewiscowper left (~lewiscowp@unaffiliated/tenmilestereo): "Textual IRC Client: www.textualapp.com"
03:27 <•jbenet> think of JSON-LD
03:27 <•jbenet> (JSON-LD is so the right way to do Linked Data, btw. We should ensure the ipfs merkledag is LD friendly.)
03:28 <•jbenet> (which it should already be, as we can represent triples, or any other doc, and we have links that can be to schemas.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
question: what about parameterized types?
you have a link to a schema, and then a blob or a link to a object/dag of that type?