Erik Post
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # CQL Developer documentation Formerly: AQL ## Abbreviations inventory (TODO add plz!) These need some documentation in the code, and maybe some of them could be renamed. Let's start by figuring out what the letters stand for, and what they mean. - `GTerm` (now named `Carrier`): should this be called `ETerm` for entity term? > yes, ETerm is better. ETerms are the carrier for the initial algebra of an instance; they are just terms. I made a separate type so this could be changed. For example aql-java just uses natural numbers as the carrier. - `TTerm` (now named `TalgGen`): type term? > yes. TTerms are the generating labelled nulls for the type algebra of the associated instance. - `nf`: normal form - `dp`: decision procedure? - `w`: More obvious ones: - tys: typeside(s) (is this also used for 'types'?) - sym: type side function/constant symbol - var: variable - fk: foreign key - en: entity - ens: entities - att: attribute - gen: generator - sk : skolem term / labelled null / (like a generator for a type rather than entity) - col: collage - sch: schema - ins: instance ## Codebase General code standards: https://hackmd.io/U8vrBv94TqK413F0GIEAfg ## Secret ingedients - `maybe`, `fromMaybe`, `either`, etc in favour of pattern matching, which is quite low-level and can't be generified - `Map.mapWithKey` - `fmap`, `<$>` - `Set.map` - `Map.fromSet` - `member` - applicatives, eg `add <$> Just 42 <*> Nothing` - `pure` instead of `return`; induces weaker `Applicative` constraint - `pure`, `mzero` could be used - `Left` and `Right` instead of`pure` and `Left`; while keeping it generic is a worthy goal, `pure` and `Left` as a combo aren't so great; as long as we're using one specialised constructors, we might as well be explicit in the other. Ryan comments: > Left should probably be replaced with a monadic/applicative/whatever 'throwError' in 95% of the code # Caution If we could get rid of some of these things in the codebase, that'd be nice; worth a bit of investigation: - avoid `fromJust`; at least mitigate by perhaps doing it properly using `Maybe`, and deferring the `fromJust` to the call site. -- Almost all of the uses of `fromJust` are places where Map lookups are guaranteed not to fail. - `absurd` -- I use these to do typesafe conversion of terms, see below - `undefined` -- Some of the `undefined` are places where code still needs to be written, but in a few places it is used deliberately, such as creating instances without theorem provers. In such places it's safely used as a null value. ## Questions - what are the `upXxx` funs for? Ryan says: > Terms are parameterized by the type of symbols they carry. For example, `Term Void Void Void en fk Void gen Void` is the type of terms on the entity side in the presentation of an instance, making explicit the fact that e.g., variables can't be present. But sometimes we want to convert the term; for example, add it to a list of `Term var ty sym en fk att gen sk`. Then we use one of the `upXxx` functions to do the conversion, by eliminating the `Void` types with `absurd`. - performance of bound `foo = toList ...` followed by operation on `foo` vs. inline version (TODO: find example) Ryan says: > there are a lot of places that look like `toMap (list map) fromMap`, because I'm not that familiar with the Map interface. Ditto for sets. These can be replaced. # Haskell, GHC and tooling things that may prove useful - warn about redundant type constraints with [--Wredundant-constraints](--Wredundant-constraints ) - infer type constraints with [PartialTypeSignatures](https://ghc.haskell.org/trac/ghc/wiki/PartialTypeSignatures#extra-constraints-wildcard) - make hlint force newline after `do` with github.com/lspitzner/brittany - use [hindent](https://github.com/commercialhaskell/hindent) to help with formatting and alignment - we use `-Werror` to make any warning into a compiler error, so we can ensure our code is syntactically correct - we use `-Weverything` to enable all the possible compiler warnings and then we disable only the undesired ones using the `-Wno-` options. FOr example we use `-Wno-unused-type-patters` to avoid warning on unused function arguments and `-Wno-name-shadowing` to allow variable name shadowing # Feature support source: [Options.hs](https://github.com/statebox/cql/blob/1609241a2c188319241d9b5ea7fe51441edb41c4/src/Language/Options.hs) - [ ] generate SQL - [ ] pivot # TODO - [ ] Erik to look at https://github.com/statebox/aql/issues/54#issuecomment-430962183 - [ ] Erik to look at `pivot` feature in Java AQL: - https://github.com/CategoricalData/fql/blob/master/src/main/java/catdata/aql/AqlPivot.java - https://github.com/CategoricalData/fql/commit/efaea9217ea4ef40f0d6e82d41eb14c250b47b5e - https://github.com/CategoricalData/fql/commit/a58d1cd13b59b422f37d69a20b91657b961eb891

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully