Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding pllua (Lua PostgreSQL Procedural Language) type annotations. #36

Merged
merged 1 commit into from
Jul 24, 2022

Conversation

fcr--
Copy link
Contributor

@fcr-- fcr-- commented Jul 24, 2022

Since pllua (Procedural Language Lua) is supposed to run inside PostgreSQL (as functions, procedures or in do blocks), it isn't distributed as a luarocks package, instead it is distributed with PostgreSQL itself. That said, it still makes sense to have type annotations for it.

Note: most comments (and field names) were copied from the pllua's documentation.

@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be consistent with check-all.sh, and btw, /bin/sh sometimes points to other shells like dash, where BASH_SOURCE is not defined.

elog: function(Severity, sqlstate: string, message: string)
elog: function(Severity, sqlstate: string, message: string, detail: string)
elog: function(Severity, sqlstate: string, message: string, detail: string, hint: string)
elog: function(Severity, ELogInfo)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to "re-export" a module or a bunch of symbols? At least being able to do something like:

local elog = require 'pllua.elog'
[...]
   elog: typeof(elog.elog)
   debug: typeof(elog.debug)
   log: typeof(elog.log)
   info: typeof(elog.info)
   notice: typeof(elog.notice)
   warning: typeof(elog.warning)
   error: typeof(elog.error)

Something like typeof would also be helpful for referencing local types that could not be exported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested type should be publicly accessible just like the record attributes, so you should be able to use elog.ELogInfo from client code that requires this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, elog.ELogInfo is being exported (and it's being used in spi.d.tl), however I meant being able to express a "poly" type and associate that to a type variable, something like type logfunction = function(message: string) & function(sqlstate: string, message: string) & ... but I guess we first would need some syntax to express type intersection.

@hishamhm hishamhm merged commit 9dc8219 into teal-language:master Jul 24, 2022
@hishamhm
Copy link
Member

Merged, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants