Skip to content

Regex implementation is missing #3

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

Open
mikesol opened this issue Jul 9, 2020 · 2 comments
Open

Regex implementation is missing #3

mikesol opened this issue Jul 9, 2020 · 2 comments

Comments

@mikesol
Copy link

mikesol commented Jul 9, 2020

https://github.com/purescript-python/purescript-strings.py/blob/master/python-ffi/Data/String/Regex.py
@Hong-Xiang could you please add a note to the readme about why these functions are not yet implemented so contributors know the challenges to overcome? If it is simple to implement them, I can do it, but if there is a blocker then it'd be helpful to know. Thanks!

@Hong-Xiang
Copy link
Collaborator

Hong-Xiang commented Jul 10, 2020

@mikesol , thanks for your attention!

Data.String.Regex and related modules is not supported yet, due problems in implementing purescript-strings/src/Data/String/Regex.js.

It seems Regex.js is a wrap on native JS RegExp and related methods, the largest problem is there are some small differences between syntax and semantics of regular expression of JS RegExp and Python's re module. There are some python libraries trying to do the translation, e.g. js-regex.

Drop support for Purescript libraries that uses Regex, and simply wrap re may be a solution, but this may cause lots of problems in future.

If we want to support PureScript libraries, we may either

  1. transform all JS RegExp to equivalent re version, but there maybe some cases there is no equivalent re version.
  2. or implement a port of JS RegExp in Python, then we may need consider performance issues

Another smaller problem is that for users of Purescript-Python, we may assume they are more familiar with Python than JavaScript, then when using a Regex lib provided by strings, the first attempt maybe direct port Python re expression,
the point is for some simple cases this may work, but they may got some subtle bugs.

About adding these notes to README, since currently I don't have a clear conclusion on how to fix this, to avoid possible misleading, how about have a discussion here and add a link in README to this issue?

@mikesol
Copy link
Author

mikesol commented Jul 10, 2020

Thanks @Hong-Xiang for the solid explanation!

Between your two suggestions, I'd recommend the second. There are several packages on pursuit (ie the tapReporter for purescript-spec) that use Data.String.Regex, so by making a python-only port, we'd close off use of those libraries.

I agree that a python-native regex library is a good idea, especially so that it is comfortable for python developers. I think that this should be a separate package, ie purescript-regex-python.

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

No branches or pull requests

2 participants