We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The documentation of GHC.Generics says this:
GHC.Generics
However, users /should not rely on a specific nesting strategy/ for :+: and :*: being used.
From reading the code it seems to me as if the code depends on the structure being balanced.
I was able to construct the following example, which breaks the logic of gPut by nesting all constructor to the left:
gPut
{-# LANGUAGE DataKinds, TypeOperators #-} import Data.Serialize import GHC.Generics type MyGeneric a = D1 ('MetaData "Foo" "Ghci2" "interactive" 'False) (((C1 ('MetaCons "Foo1" 'PrefixI 'False) U1 :+: C1 ('MetaCons "Foo2" 'PrefixI 'False) U1) :+: C1 ('MetaCons "Foo3" 'PrefixI 'False) U1) :+: C1 ('MetaCons "Foo1" 'PrefixI 'False) U1) a x :: MyGeneric a x = M1 $ L1 $ L1 $ L1 $ M1 U1 y :: MyGeneric a y = M1 $ L1 $ L1 $ R1 $ M1 U1 test :: Either String (Bool, Bool) test = (\z -> (z == x, z == y)) <$> runGet gGet (runPut $ gPut x) main :: IO () main = print test
When I run the code it outputs Right (False,True), which shows that the encoding and decoding of x isn't equal to x itself, but equal to y.
Right (False,True)
x
y
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The documentation of
GHC.Generics
says this:From reading the code it seems to me as if the code depends on the structure being balanced.
I was able to construct the following example, which breaks the logic of
gPut
by nesting all constructor to the left:When I run the code it outputs
Right (False,True)
, which shows that the encoding and decoding ofx
isn't equal tox
itself, but equal toy
.The text was updated successfully, but these errors were encountered: