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

Lua filters: preload text module #4077

Merged
merged 1 commit into from
Nov 18, 2017
Merged

Lua filters: preload text module #4077

merged 1 commit into from
Nov 18, 2017

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Nov 16, 2017

The text module is preloaded in lua. The module contains some UTF-8
aware string functions, implemented in Haskell. The module is loaded on
request only, e.g.:

text = require 'text'
function Str (s)
  s.text = text.upper(s.text)
  return s
end

@tarleb
Copy link
Collaborator Author

tarleb commented Nov 16, 2017

It's a tiny package, so always loading it on startup would be possible. However, it seems safer and more backwards compatible to not pollute the global namespace.

@tarleb
Copy link
Collaborator Author

tarleb commented Nov 16, 2017

Functions provided by that module: lower, upper, reverse, len, and sub.

@jgm
Copy link
Owner

jgm commented Nov 16, 2017

Looks good. Will wait til you've released the library before merging (then it will work with cabal builds).

One thought: I suppose it's too radical an idea to inject these functions into string, so that string.upper "just works"?

@tarleb
Copy link
Collaborator Author

tarleb commented Nov 16, 2017

It's now published on hackage. I hadn't tested GHC 7.8 compatibility, will fix in the morning.

One thought: I suppose it's too radical an idea to inject these functions into string, so that string.upper "just works"?

This would be nice, but I'd not be very comfortable doing so unless we also replace all pattern-handling functions like find and match. I don't expect to get around to that in the near future.

@jgm
Copy link
Owner

jgm commented Nov 16, 2017

We should also add documentation to the lua-filters.md document. (This could be done in a separate request if you prefer.)

The `text` module is preloaded in lua. The module contains some UTF-8
aware string functions, implemented in Haskell.  The module is loaded on
request only, e.g.:

    text = require 'text'
    function Str (s)
      s.text = text.upper(s.text)
      return s
    end
@tarleb tarleb changed the title WIP Lua filters: preload text module Lua filters: preload text module Nov 17, 2017
@jgm jgm merged commit 53aafd6 into jgm:master Nov 18, 2017
@tarleb tarleb deleted the lua-text-module branch November 18, 2017 21:41
jgm added a commit that referenced this pull request Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants