Skip to content

Drop unicode dependency? #198

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

Closed
jamesdbrock opened this issue May 26, 2022 · 5 comments
Closed

Drop unicode dependency? #198

jamesdbrock opened this issue May 26, 2022 · 5 comments

Comments

@jamesdbrock
Copy link
Member

Does the unicode dependency make the bundle size much larger?

https://discourse.purescript.org/t/dear-purescript-parsing-users/2620/9

@jamesdbrock
Copy link
Member Author

@jamesdbrock
Copy link
Member Author

@jamesdbrock
Copy link
Member Author

So, as @natefaubion pointed out on Discourse, the large bundle sizes from unicode are due to the lookup tables.

A program which runs runParser "a" (char 'a'):

spago -x spago-dev.dhall bundle-module --main Test.Unicode --platform node --minify
[info] Build succeeded.

  index.js  13.7kb

A program which runs runParser "a" letter:

spago -x spago-dev.dhall bundle-module --main Test.Unicode --platform node --minify
[info] Build succeeded.

  index.js  150.4kb

@jamesdbrock
Copy link
Member Author

I added some documentation about unicode bundle size in v9.1.0 explaining that if none of the unicode-dependent functions are used then all of the unicode package will be eliminated by dead-code-elimination. https://pursuit.purescript.org/packages/purescript-parsing/9.1.0/docs/Parsing.String.Basic

@jamesdbrock
Copy link
Member Author

The unicode parsers in Basic like i.e. upper are slightly more useful than satisfyCodePoint isUpper because they return a Char rather than a CodePoint. So that's a reason to keep them. They encode the knowledge that in fact all of the Unicode uppercase characters are members of the Basic Multilingual Plane, and that knowledge is not otherwise available to the type system.

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

No branches or pull requests

1 participant