Last active
April 8, 2018 12:30
-
-
Save secondwtq/4bcf787415132d630469b03c0d9427ee to your computer and use it in GitHub Desktop.
Prototyping PADD, the query interface for LCARS.
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
using _ = personal#olive; | |
using _f = _#typography; | |
using _et = _#entityType; | |
ensure _et#typeface; | |
lhs isSimilarTo rhs = { | |
bidirectionalEdge <-similarTo> lhs rhs; | |
} | |
_f#fontArial isSimilarTo _f#fontHelvetica; | |
_f#fontArial do { | |
isA _et#typeface; | |
prop :publishedAt 1996; | |
isSimilarTo _f#Helvetica; | |
}; | |
# `#` is the comment symbol? | |
# the file extension ... | |
# * maybe ".ll" for *"LCARS List"* | |
# * or ".ns" for *"Newspeak"* | |
# (".l" is not available, it's for LISP ...) | |
type id = | |
| root | |
| levelUp (id, string) | |
* DB primitive types (lang. basic primitive (intrinsic) type marked with X): | |
* `id` X - no DB type | |
# * `scope` X - no DB type | |
* `string` X - PG DATE (Unicode?) | |
* `i16` X - PG SMALLINT | |
* `i32` X - PG INT | |
* `double` X - PG REAL/FLOAT8 | |
* `T[]` X - PG ARRAY | |
* TODO: numeric/decimal | |
* `date` - PG DATE | |
* `time` - PG TIME | |
* `timestamp` - PG LONG | |
* `datetime` - PG TIMESTAMPZ | |
* `interval` - PG INTERVAL | |
* TODO: `json` - PG JSONB | |
* `uuid` - PG UUID | |
* ... well there are so many types ... | |
* expression: | |
* `? ($queryPatterns) { predicates }` - QUERY clause, quasi-SELECT in SQL | |
* `$$identifier` - Pattern Variable (explicit for impl. conv.) | |
* `let $pattern = $expression` - let-binding | |
module basis { | |
entry entry_base { | |
:eid: uuid, | |
:id: id, | |
:utcCreated: timestamp, | |
let constructor (id: id) | |
{ :id id, | |
:eid uuid.generate(), | |
:utcCreated timestamp.now() } | |
} | |
entry Entity: entry_base { | |
:name: string; | |
} | |
entry Edge: entry_base { | |
} | |
let newAge (): id = | |
#edge ## (randomId ()) | |
entry Tag: entity { | |
let constructor (name: string) { | |
} | |
let create (name: string) = | |
#tag ## (name.lowercase) <- Tag name | |
} | |
entry URL: entity { | |
protocol: string; | |
href: string; | |
title: string; | |
} | |
} | |
open basis | |
module media { | |
entry Image: entity { | |
:name: string, | |
:sha1: string, | |
} | |
entity Sticker: entity { | |
:text: string, | |
:image: Image, | |
} | |
} | |
module typography { | |
entry Font: entity { | |
} | |
} | |
module secondwtq { | |
} | |
open secondwtq | |
# To ensure all stuff are synchronized and consistent, | |
# only :eid is stored for entites in memory | |
Tag.create "OCaml"; | |
Tag.create "金馆长"; | |
let fonts = ? ($fontA, $fontB) { | |
fontA.publishedAt == 1996 && | |
#namespace#in _f fontA.id && | |
bidirectionalEdgeBetween <-similarTo> fontA fontB | |
}; | |
--- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment