knrafto / language-bash

Parse and pretty-print Bash shell scripts
BSD 3-Clause "New" or "Revised" License
35 stars 9 forks source link

Expose ByteString version of 'parse' #37

Open hasufell opened 4 years ago

hasufell commented 4 years ago

https://hackage.haskell.org/package/language-bash-0.9.0/docs/Language-Bash-Parse.html#v:parse is only String. That is really unfortunate. String is both a weird (not even UTF-8) format and is unefficient. I generally don't use it at all.

Nothing else from the module is exposed, so it's hard to build my own version without forking the library.

knrafto commented 4 years ago

Should the interface use Text instead of ByteString? In other words, is it safe to assume all bash scripts are Unicode and not arbitrary binary data?

hasufell commented 4 years ago

In other words, is it safe to assume all bash scripts are Unicode and not arbitrary binary data?

I don't think arbirary binary data is allowed. But some binary data works just fine as strings for example. I would provide both ByteString and Text version and drop String entirely.

I noticed some things in the AST end up as Char. I'm not sure how well that would work when parsing as ByteString.