I was talking to James about this today in a PureScript Contrib call. In short, we’re trying to reduce the “fear of the unknown” of the breakage this change might cause. This post is an attempt to find the people who use this library and how, so that they might be included in the conversations around changes we could make.
If no one uses this library, then that gives James more freedom to make design decisions as he sees fit.
I have never taken advantage of StringLike, but I believe it exists so you can do things like parse using List Char if you were so inclined. What would need to change to handle unicode properly with StringLike (the requirements of this alternative were not mentioned in the ticket)? Was there discussion about why StringLike was introduced, or was it just “maybe this is useful”?
Now that yall mentioned unicode, I wonder, is the dependency on the unicode package really necessary? I’m pretty sure I had to drop this lib from a previous project because of the insane bundle sizes (ended up ffi-ing to nearley)
I agree that purescript-unicode leads to excessive bundle sizes. I don’t think there’s a reason that it couldn’t be trimmed significantly, but it would require someone making a dedicated effort to help with that.
I’m probably about to be schooled because there’s a better way to do this (or maybe it already exists!), but I recently had to write something like:
word :: Parser String String
word = do
chars <- some alphaNum
pure $ String.fromCodePointArray $ (String.codePointFromChar <$> chars)
which I could imagine being simpler if I was parsing a List Char instead of a String. Still I doubt there would be cases where it would be advantageous for a whole parser to work on List Char when you consider performance.
Currently there is no better way to write your word parser, but there should be. Deleting the StringLike class will allow us to add new primitive parsers like takeWhileP :: (CodePoint -> Boolean) -> Parser String String so that we can take advantange of the O(1) JavaScript immutable String slicing and write your parser as
word :: Parser String String
word = takeWhileP isAlphaNum
I use StringLike a => a lot, but only because a heap of code I was using used it and defining my own stuff as String → broke stuff when composing the parsers - in that way it was a annoyingly viral.
So as much as it’d be a pain for me to strip it from my own parsers, the ported parsers (I think perhaps formatters?) and the datetime-parser, I’d be in favour of this because it’d mean that kind of code wouldn’t be needed.
I use the Erlang backend, which has… immutable string slicing so I imagine anything we do could take advantage of this too when re-writing the FFI.