-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added hPutStr and hPutStrLn to the Print module #197
Conversation
First of all, thank you for contribution.
I've been thinking about that and I realized that it might be a good idea to have a module called e. g. Apart from that, I think there are two more things which can be improved in the
|
I pushed a version that implements the Print-as-internal-class suggestion of A few things that came to me while I was writing it:
Also I chose to name the methods of |
I've been thinking about it and currently I'd rather not add these functions because they are not standard (I found functions with these names only in some packages which I've never seen before). It's not bad per se, but earlier we realized that we have too many non-standard functions which make it harder for new people to get used to
I think it's fine to add |
@JustusAdam thank you for the PR. Regarding your last questions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add hPrint
and I'll approve.
As per the suggestion of @gromakovsky Also added some docs Also added the requested SPECIALIZE pragmas
Used documentation similar to `print` Added SPECIALIZE pragma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, forgot one last thing: changelog update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
As per the suggestion of @gromakovsky Also added some docs Also added the requested SPECIALIZE pragmas
Used documentation similar to `print` Added SPECIALIZE pragma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I thought about multiparameter type class "Print", but it would be unnesessary complication....
As per the suggestion of @gromakovsky Also added some docs Also added the requested SPECIALIZE pragmas
Used documentation similar to `print` Added SPECIALIZE pragma
Problem
I was rather surprised to find that Universum does not export a version of
hPutStrLn
andhPutStr
etc.Solution
This PR adds both
hPutStr
as well ashPutStrLn
toUniversum.Print
.putStr
as well asputStrLn
are still available and exported fromUniversum.Print
.Implementation considerations
I decided, in the spirit of a smaller surface area and code of
Universum.Print
, to completely switch thePrint
class methods.My logic was that this is a class people rarely implement themselves. (It may perhaps even be prudent not to export
hPutStrLn
andhPutStr
as methods but as normal functions instead).I am open for comments and improvement suggestions though.
Alternatives
Additional
HPrint
typeclassAn extra type class that encodes printing to handles.
This avoids the problem of possibly breaking backwards compatibility by changing the signature and names of methods in
Print
but means more code and a larger surface area for the module.The methods for
Print
may also have default signatures that utilizeHPrint