statebox / cql

CQL: Categorical Query Language implementation in Haskell
GNU Affero General Public License v3.0
162 stars 14 forks source link

71/prettyprint #83

Closed epost closed 5 years ago

epost commented 5 years ago

This is my first batch of changes resulting from looking at prettyprinting stuff.

The build fails due to missing tabular dependency, which I added to Stack's package.yaml but not to the nix build yet, so it's not ready for merging yet; tomorrow, hopefully.

marcosh commented 5 years ago

:+1:

epost commented 5 years ago

This seems useful enough to be merged for now. I have more stuff in mind around output and formatting, but it'd be nice to have this on master.

epost commented 5 years ago

Output looks like this btw:

algebra
"Department" (1)
+---------------++--------------------------+------------------------+
|               || "secretary" : "Employee" |      "name" : "string" |
+===============++==========================+========================+
| "a"."worksIn" ||                      "a" | ("a"."worksIn","name") |
+---------------++--------------------------+------------------------+

"Employee" (2)
+-----++------------------------+--------------------------+---------------+--------------------+-------------------+
|     || "manager" : "Employee" | "worksIn" : "Department" | "age" : "nat" | "first" : "string" | "last" : "string" |
+=====++========================+==========================+===============+====================+===================+
| "a" ||                    "a" |            "a"."worksIn" |   ("a","age") |      ("a","first") |      ("a","last") |
+-----++------------------------+--------------------------+---------------+--------------------+-------------------+
| "b" ||                    "a" |            "a"."worksIn" |   ("b","age") |      ("b","first") |      ("b","last") |
+-----++------------------------+--------------------------+---------------+--------------------+-------------------+

type-algebra
nulls
  "nat" (2) = [("a","age"),("b","age")]
  "string" (5) = [("a"."worksIn","name"),("a","first"),("a","last"),("b","first"),("b","last")]