Closed daniel-beard closed 2 years ago
Hey @daniel-beard, I can't really help with permutation parsers because it wasn't me who wrote this functionality. Let's try to ping @recursion-ninja.
Let me take a look at this. I'm quite busy the next two days but on Wednesday or Thursday I should be able to carve out some time.
I closed the ticket as I was able to get the behavior I wanted with this:
pFlags :: Parser [Flag]
pFlags = runPermutation $ removeMaybes <$>
toPermutationWithDefault Nothing (Just GroupFlag <$ char '\'') <*>
toPermutationWithDefault Nothing (Just LeftJustifyFlag <$ char '-') <*>
toPermutationWithDefault Nothing (Just ShowSignFlag <$ char '+') <*>
toPermutationWithDefault Nothing (Just SpaceFlag <$ char ' ') <*>
toPermutationWithDefault Nothing (Just AltFlag <$ char '#') <*>
toPermutationWithDefault Nothing (Just ZeroFlag <$ char '0')
where removeMaybes a b c d e f = catMaybes [a,b,c,d,e,f]
@daniel-beard Good to hear! It wasn't obvious to me why the issue was closed (maybe you had lost any hope of getting a response!), that's why I re-opened it. I'm going to close it now, however if @recursion-ninja finds time to look at this, I guess his comment is still welcome.
I'm attempting to parse permutations of flags. The behavior I want is "one or more flags in any order, without repetition".
The code I have is outputting what I want, but is too lenient on inputs. I don't understand why it's accepting multiples of the same flags. What am I doing wrong here?
Example inputs / outputs: