Replies: 2 comments 2 replies
-
Hey @mayoff, thanks for bringing this up! It's actually something @stephencelis and I discussed quite a bit before open sourcing. We're still not sure where to draw the line. We're kinda following Combine's lead here. Your suggestion is interesting, but unfortunately would only work when implementing a parser by conforming a type to the We're happy to discuss this more, but it might be better to do so in the discussions tab. This is our first time using this GitHub feature. |
Beta Was this translation helpful? Give feedback.
-
@mayoff Thanks for starting the discussion! We're definitely open to refine the ergonomics of the library. As far as our mentality has been with what we've shipped so far, @mbrandonw pointed out that we've mostly tried to follow Combine's lead. This means establishing a few loose rules:
One other thing we do for 2. and 3. is add a convenience type alias to them inside the While we have established these rules, the reality is that they are loose and could be refined. For example:
If you have any specific ideas we'd love to hear them! We'd also love to hear of any specific instances in which having top-level parser types interferes with your workflow. Are you having a conflict in a particular code base because of our |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is just a humble suggestion from a fan.
I see that you have an
public enum Parsers { }
to use as a namespace, like Combine does with thePublishers
type. But you've still defined several parser types (likeLazy
,Prefix
, andFirst
) at module scope, to make it more convenient to use them. But this is likely, particularly in the case ofLazy
, to conflict with names from other modules.Here's an alternative to consider: put all the parser types in the
Parsers
namespace. Then define a protocolParserUsing
that “imports” those names as type aliases. Example:Since
Parser
is a subprotocol ofParserUsing
, everyParser
automatically conforms toParserUsing
and has access to the type aliases. And sinceParsers
conforms toParserUsing
, the same is true in every extension ofParsers
.Further, any type that builds a parser can add a conformance to
ParserUsing
to import the type aliases. Example:Beta Was this translation helpful? Give feedback.
All reactions