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

Allow creation of user-defined TypeMapping's. #172

Closed
wants to merge 1 commit into from
Closed

Allow creation of user-defined TypeMapping's. #172

wants to merge 1 commit into from

Conversation

rblaze
Copy link
Contributor

@rblaze rblaze commented Jun 2, 2016

I need one to create Haskell-stype qualified names, but can't create it, and have to reimplement several functions.

@msftclas
Copy link

msftclas commented Jun 2, 2016

Hi @rblaze, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Andrey Sverdlichenko). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@lalo
Copy link
Member

lalo commented Jun 3, 2016

We would just have to bump the GBC version number to reflect the change or bundle it on the next release which already a different version number. The failed travis iteration is not related to this PR.

@rblaze
Copy link
Contributor Author

rblaze commented Jun 3, 2016

As a side note, it would be great to have next release, also because of aeson version bump. Currently bond can't be built with stackage lts-6 because of it.

@lalo
Copy link
Member

lalo commented Jun 3, 2016

@rblaze by Aeson bump you mean the one that is already on master right? 0fead8d

@rblaze
Copy link
Contributor Author

rblaze commented Jun 3, 2016

Exactly, 0.12 works just fine.

@@ -17,7 +17,7 @@ type system of a target programming language.
module Language.Bond.Codegen.TypeMapping
( -- * Mapping context
MappingContext(..)
, TypeMapping
, TypeMapping(..)
Copy link
Member

@chwarr chwarr Jun 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeMapping also refers to TypeNameBuilder. While we don't need to export that from the module because it's just a type alias, doing so would allow you to use TypeNameBuilder instead of Reader MappingContext Builder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment for TypeMapping needs to be updated. It's no longer opaque.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also worth considering if we shouldn't export some of the helpers that are usually needed to create a TypeMapping. In particular I'm thinking about elementTypeName, instanceTypeName, annotatedTypeName, aliasTypeName, declTypeName and declQualifiedTypeName.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this, pushed updated commit.

@lalo
Copy link
Member

lalo commented Jun 6, 2016

I think it looks good, the only nit I see is the new uncommented functions (elementTypeName, instanceTypeName, annotatedTypeName, aliasTypeName, declTypeName and declQualifiedTypeName) since I noticed a pattern that if its exposed it has a small comment.

@rblaze
Copy link
Contributor Author

rblaze commented Jun 6, 2016

Could you provide me with descriptions to add? I'm a bit struggling to come up with good ones.

@sapek
Copy link
Contributor

sapek commented Jun 7, 2016

How about something along these lines:

-- | Builder for nested element types (e.g. list elements) in context of 'TypeNameBuilder' monad. 
-- Used to implement 'mapType' function of 'TypeMapping'.
elementTypeName :: Type -> TypeNameBuilder

-- | Builder for the qualified name for a 'Declaration' in context of 'TypeNameBuilder' monad.
-- Used to implement 'mapType' function of 'TypeMapping'.
declQualifiedTypeName :: Declaration -> TypeNameBuilder

Also I think we actually don't need to export instanceTypeName and annotatedTypeName. They are never used to build type mappings.

I need one to create Haskell-stype qualified names, but can't create it, and have to reimplement several functions.
@rblaze
Copy link
Contributor Author

rblaze commented Jun 7, 2016

Updated pull request.

@chwarr
Copy link
Member

chwarr commented Jun 7, 2016

LGTM. I'll merge this tomorrow.

@msftclas
Copy link

msftclas commented Jun 7, 2016

@rblaze, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@chwarr
Copy link
Member

chwarr commented Aug 23, 2016

Version 0.5.0.0 of the bond package is now live on Hackage. That version includes this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants