Created
October 26, 2015 02:38
-
-
Save maurer/6dedbdb777891172a9b2 to your computer and use it in GitHub Desktop.
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
@0xaaef86128cdda946; | |
using Schema = import "schema.capnp"; | |
interface Holmes { | |
# Capnproto Type Description | |
using Node = Schema.Node; | |
# Dynamically typed holmes value (a pointer to anything non interface) | |
using Val = AnyPointer; | |
# Types according to capnproto | |
using Type = Schema.Type; | |
# Variable representation - text will be slower, but easier to debug | |
using Var = Text; | |
# Assignment from variables to something | |
struct Context(T) { | |
entries @0 :List(Entry); | |
struct Entry { | |
var @0 :Var; | |
val @1 :T; | |
} | |
} | |
# Logical facts | |
using PredName = Text; | |
struct Pred { | |
name @0 :PredName; | |
type @1 :Type; | |
} | |
struct Fact { | |
predicate @0 :PredName; | |
arg @1 :Val; | |
} | |
struct BodyExpr { | |
union { | |
unbound @0 :Void; | |
var @1 :Var; | |
const @2 :Val; | |
} | |
} | |
struct BodyClause { | |
predicate @0 :PredName; | |
args @1 :Context(BodyExpr); | |
} | |
struct FExpr { | |
func @0 :Text; | |
args @1 :List(Expr); | |
} | |
struct Expr { | |
union { | |
var @0 :Var; | |
val @1 :Val; | |
app @2 :FExpr; | |
} | |
} | |
struct BindExpr { | |
union { | |
normal @0 :BodyExpr; | |
iterate @1 :BodyExpr; | |
} | |
} | |
struct WhereClause { | |
lhs @0 :Context(BindExpr); | |
rhs @1 :Expr; | |
} | |
struct Rule { | |
head @0 :List(BodyClause); | |
body @1 :List(BodyClause); | |
where @2 :List(WhereClause); | |
} | |
interface Func { | |
types @0 ()->(input : Type, | |
output : Type); | |
run @1 (arg : Val) -> (result : Val); | |
} | |
# Register a predicate | |
newPredicate @0 (predName :PredName, | |
type :Type); | |
# Add a fact to the extensional database | |
newFact @1 (fact :Fact); | |
# Ask the server to search or expand the intensional database | |
# searching for a set of facts that matches a body clause | |
# Returns the list of satisfying assignments to the body clauses. | |
derive @2 (query :List(BodyClause)) -> (ctxs :List(Context(Val))); | |
# Add a rule to expand the intentional database | |
newRule @3 (rule :Rule) -> (); | |
# Register a new external function | |
newFunc @4 (name :Text, func :Func); | |
# Load types into the system | |
loadTypes @5 (nodes :List(Node)) -> (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment