AJChapman / formatting

Format strings type-safely with combinators
BSD 3-Clause "New" or "Revised" License
164 stars 39 forks source link

Spaced combination operator #75

Closed phadej closed 1 year ago

phadej commented 2 years ago

Related idea is to have <+> operator to do the same thing for <>. Then

let formatPeople = format (int % " " <> plural "person" "people" % ".")

could be written as

let formatPeople = format (int <+> plural "person" "people" % ".")

if so, maybe %% should be named %+.

AJChapman commented 2 years ago

@phadej, I like this idea. What about calling the operator %_ (or _%)? And then for the <+> idea we could use <_>?

phadej commented 2 years ago

_ is not an operator character

phadej commented 2 years ago

ping

AJChapman commented 2 years ago

Sorry about being slow on this. I've just pushed this change, after which I rename (%%) to (%+) and add (<%+>). Is the latter a good name, do you think? I wonder whether I should add (<%>) as another name for (<>) to keep the naming consistency...

phadej commented 2 years ago

If you are unsure, then better to not add new combinators. They can be added later if it feels like so, removing OTOH is a breaking change.