-
Notifications
You must be signed in to change notification settings - Fork 8
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
stable encoding #21
stable encoding #21
Conversation
encodeDecimal d@(Decimal _ mantissa) | ||
| isSafeInteger mantissa = J.build $ J.Aeson @Scientific $ fromRational $ toRational d | ||
| otherwise = J.object [ "decimal" J..= T.pack (show d) ] | ||
encodeUnit = J.object ["unit" J..= T.empty] -- TODO: Discuss? |
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.
@jmcardon How should we handle unit
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.
I think the empty text is fine 👍
-- | Stable encoding of `CapabilityGuard FullyQualifiedName PactValue` | ||
instance J.Encode (StableEncoding (CapabilityGuard FullyQualifiedName PactValue)) where | ||
build (StableEncoding (CapabilityGuard name args)) = J.object | ||
[ "cgPactId" J..= (error "a" :: T.Text) -- TODO: Check availability |
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.
@jmcardon same here
instance J.Encode (StableEncoding ModRef) where | ||
build (StableEncoding (ModRef mn imp _ref)) = J.object | ||
[ "refSpec" J..= J.Array (StableEncoding <$> imp) | ||
-- , "refInfo" J..= _modRefInfo o |
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.
@jmcardon same here
PGuard g -> J.build (StableEncoding g) | ||
PObject o -> J.build (StableEncoding o) | ||
PModRef mr -> J.build (StableEncoding mr) | ||
PCapToken _ct -> error "not implemented" |
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.
@jmcardon and here
|
||
-- | | ||
-- | ||
-- Stable encoding which matches Pacts StableEncoding. |
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.
Some questions that could be addressed as documentation here in the haddock header:
- What is this stable encoding for?
- Where will the encoded results end up?
- How stable does the encoding need to be? vis. the following question
- What happens if we find a bug in the encoding and need to fix it?
- Does this encoding constitute a public API? Will users/clients consume/produce values in this encoding, or is it internal?
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.
In Robert's absence, I can answer some of these, and maybe @rsoeldner can include this in the haddocks in a separate PR.
- Stable encoding is for hashes and anything that produces an identifier with hashes, that is
principal
s,pactId
s, etc. - The encoded results may be pactIds, or even semantic values produced by
hash
- The encoding must match production. I've ported over some tests on
hash.repl
but this is not enough, soon with the new module hashing, we will use repl tests as goldens to ensure some of our hashes are computably stable. - There should not be bugs in the encoding. It has to match prod 1-1 and we have to enforce this long term. There cannot be bugs in this code when we launch core to the world.
- This encoding may possibly be an API, but we're not even sure what core's API will be like yet. We cross that bridge when we get there, I think.
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.
Adds lots of things I could use for my stuff, so looking forward to it!
encodeDecimal d@(Decimal _ mantissa) | ||
| isSafeInteger mantissa = J.build $ J.Aeson @Scientific $ fromRational $ toRational d | ||
| otherwise = J.object [ "decimal" J..= T.pack (show d) ] | ||
encodeUnit = J.object ["unit" J..= T.empty] -- TODO: Discuss? |
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.
I think the empty text is fine 👍
|
||
-- | | ||
-- | ||
-- Stable encoding which matches Pacts StableEncoding. |
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.
In Robert's absence, I can answer some of these, and maybe @rsoeldner can include this in the haddocks in a separate PR.
- Stable encoding is for hashes and anything that produces an identifier with hashes, that is
principal
s,pactId
s, etc. - The encoded results may be pactIds, or even semantic values produced by
hash
- The encoding must match production. I've ported over some tests on
hash.repl
but this is not enough, soon with the new module hashing, we will use repl tests as goldens to ensure some of our hashes are computably stable. - There should not be bugs in the encoding. It has to match prod 1-1 and we have to enforce this long term. There cannot be bugs in this code when we launch core to the world.
- This encoding may possibly be an API, but we're not even sure what core's API will be like yet. We cross that bridge when we get there, I think.
No description provided.