cdepillabout / pretty-simple

pretty-printer for Haskell data types that have a Show instance
https://hackage.haskell.org/package/pretty-simple
BSD 3-Clause "New" or "Revised" License
243 stars 29 forks source link

Fix parsing for identifiers containing "'" #65

Closed georgefst closed 4 years ago

georgefst commented 4 years ago

Closes #63.

This works by simply using the same logic for ' that we use for digits w.r.t. appearing in identifiers. Obviously they're not entirely equivalent in general because ' can only appear at the end of an identifier, but I don't believe there's any situation here where that difference is important.

sjakobi commented 4 years ago

Thanks a lot for fixing the bug I caused! :)

' can only appear at the end of an identifier

That's actually not true: Don't is a valid constructor name!

Could you add a test for that?

georgefst commented 4 years ago

Don't is a valid constructor name!

Well I never... I must be thinking of a different language.

That actually makes me more confident this is correct, although more tests could never hurt.

cdepillabout commented 4 years ago

@georgefst Thanks for fixing this, and @sjakobi thanks for doing a review here!

I'd be happy to merge this in once @georgefst adds one small test for constructors like Don't as suggested by @sjakobi.

georgefst commented 4 years ago

@cdepillabout Tests added.

Just realised you might not have got a notification for that.

cdepillabout commented 4 years ago

Looks good, thanks a lot for fixing this!

> data Dont' = Don't' deriving Show
> pPrint ([Right (Just Don't'), Right Nothing, Left 'a' ])
[ Right ( Just Don't' )
, Right Nothing
, Left 'a'
]
cdepillabout commented 4 years ago

Released as 3.2.3.0 on hackage:

https://hackage.haskell.org/package/pretty-simple-3.2.3.0

georgefst commented 4 years ago

Woo! Thanks for the credit.

PS. looks like you missed out the --doc upload.

cdepillabout commented 4 years ago

@georgefst pretty-simple doesn't have many dependencies, so Hackage is usually able to upload the documentation.

However, if you notice it doesn't appear within a couple hours, feel free to ping me and I'll upload it!

georgefst commented 4 years ago

Oh cool, I had no idea Hackage did that.