Skip to content
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

Add typeName function to Relude.Extra.Typeable module #89

Closed
chshersh opened this issue Oct 3, 2018 · 3 comments
Closed

Add typeName function to Relude.Extra.Typeable module #89

chshersh opened this issue Oct 3, 2018 · 3 comments
Labels
extra Relude.Extra Hacktoberfest https://hacktoberfest.digitalocean.com/ new Bring something new into library (add function or type or interface)

Comments

@chshersh
Copy link
Contributor

chshersh commented Oct 3, 2018

The following function is very useful:

typeName :: forall a . Typeable a => Text

I'm tired of copy-pasting it in every my project. So I think it's a good idea to implement it directly in relude.

@chshersh chshersh added new Bring something new into library (add function or type or interface) Hacktoberfest https://hacktoberfest.digitalocean.com/ extra Relude.Extra labels Oct 3, 2018
@cronokirby
Copy link
Collaborator

Should we create a new module Relude.Extra.Typeable to put this in then?

@cronokirby
Copy link
Collaborator

In terms of the implementation, is there a better way of getting a text from the ShowS you get from Typeable.showsTypeRep other than pack . ($ "")

@chshersh
Copy link
Contributor Author

chshersh commented Oct 3, 2018

@cronokirby

Should we create a new module Relude.Extra.Typeable to put this in then?

Well, it definitely should go in some Extra module because typeName is very popular and for alternative prelude we usually don't want to spoil global namespace with conflicting names. And I can't think of better name... There's no such module among existing modules where we can put typeName, so, yeah, guess we need to create separate module. Another idea: we can call it Relude.Extra.Type to put all type-related functionality there.

is there a better way of getting a text from the ShowS

You can just use show on TypeRep to show, it will do the trick 👍

chshersh pushed a commit that referenced this issue Oct 5, 2018
* adds an asumMap function to Foldable

* [#81] updates CHANGELOG.md to reflect asumMap addition

* [#81] Simplifes asumMap, adding an inline pragma, and bumps the package version to 0.3.1

* [#81] Removes a line of whitespace on CHANGELOG to keep formatting consistent

* [#86] adds Hlint rules for 'asumMap'

* updates .hlint.yaml file and fixes hlint.dhall syntax

* [#86] Avoids composition in asumMap hlint rules to play nicer with hlint

* [#86] adds both point free and pointful rules for asumMap in hlint, and updates yaml

* [#86] fixes the first asumMap rule

* [#89] adds Relude.Extra.Type module, containing a typeName function

* updates changelog

* [#89] Formatting: adds line of separation between Relude and other module imports

* [#89] Makes typeName inlineable and have 2 implementations to support ghc 8.0

* [#89] Updates Relude module documentation to talk about Relude.Extra.Type

* Readds accidentally deleted line of documentation [ci skip]

* Simplifies documentation example for typeName [ci skip]

* fixes parentheses in documentation for typeName
chshersh pushed a commit that referenced this issue Oct 6, 2018
* adds an asumMap function to Foldable

* [#81] updates CHANGELOG.md to reflect asumMap addition

* [#81] Simplifes asumMap, adding an inline pragma, and bumps the package version to 0.3.1

* [#81] Removes a line of whitespace on CHANGELOG to keep formatting consistent

* [#86] adds Hlint rules for 'asumMap'

* updates .hlint.yaml file and fixes hlint.dhall syntax

* [#86] Avoids composition in asumMap hlint rules to play nicer with hlint

* [#86] adds both point free and pointful rules for asumMap in hlint, and updates yaml

* [#86] fixes the first asumMap rule

* [#89] adds Relude.Extra.Type module, containing a typeName function

* updates changelog

* [#89] Formatting: adds line of separation between Relude and other module imports

* [#89] Makes typeName inlineable and have 2 implementations to support ghc 8.0

* [#89] Updates Relude module documentation to talk about Relude.Extra.Type

* Readds accidentally deleted line of documentation [ci skip]

* Simplifies documentation example for typeName [ci skip]

* fixes parentheses in documentation for typeName

* [#92] Adds a Relude.Extra.Tuple module with a 'dupe' function

* [#92] Adds 'mapToFst' and 'mapToSnd' to Extra.Tuple

* [#92] Adds a mapBoth function

* [#92] Inlines everything in Relude.Extra.Tuple

* Updates changelog

* Updates documentation in Relude module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extra Relude.Extra Hacktoberfest https://hacktoberfest.digitalocean.com/ new Bring something new into library (add function or type or interface)
Projects
None yet
Development

No branches or pull requests

2 participants