Roundtrip expression.Ty test occasionally fails
Description
Roundtrip via Expression
test failed at least once
Right (Ty (TPair % % @ @ (Ty TKey :) (Ty (TPair % % @ @ (Ty TKey :) (Ty (TMap (Ty (TPair % % @ @_ (Ty TInt :) (Ty (TPair % % @ @ (Ty TInt :) (Ty TInt :)) :)) :) (Ty TKey :)) :)) :)) :)
---
Right (Ty (TPair % % @ @ (Ty TKey :) (Ty (TPair % % @ @ (Ty TKey :) (Ty (TMap (Ty (TPair % % @ @ (Ty TInt :) (Ty (TPair % % @ @ (Ty TInt :) (Ty TInt :)) :)) :) (Ty TKey :)) :)) :)) :)
Apparently, @_
annotation gets eaten during the conversion to Expression
.
This seems similar to #616 (closed)
Full log:
Ty: FAIL (0.08s)
✗ Ty failed at src/Test/Cleveland/Util.hs:260:7
after 90 tests and 35 shrinks.
┏━━ src/Test/Cleveland/Util.hs ━━━
240 ┃ roundtripTree
241 ┃ :: forall x y err.
242 ┃ ( Show x
243 ┃ , Show y
244 ┃ , Show err
245 ┃ , Typeable x
246 ┃ , Eq x
247 ┃ , Eq err
248 ┃ , HasCallStack
249 ┃ )
250 ┃ => Gen x
251 ┃ -> (x -> y)
252 ┃ -> (y -> Either err x)
253 ┃ -> TestTree
254 ┃ roundtripTree genX xToY yToX = testProperty typeNameX prop
255 ┃ where
256 ┃ typeNameX = show $ typeRep (Proxy @x)
257 ┃ prop :: Property
258 ┃ prop = property $ do
259 ┃ x <- forAll genX
┃ │ Ty (TPair % % @ @ (Ty TKey :) (Ty (TPair % % @ @ (Ty TKey :) (Ty (TMap (Ty (TPair % % @ @_ (Ty TInt :) (Ty (TPair % % @ @ (Ty TInt :) (Ty TInt :)) :)) :) (Ty TKey :)) :)) :)) :
260 ┃ tripping x xToY yToX
┃ ^^^^^^^^^^^^^^^^^^^^
┃ │ ━━━ Original ━━━
┃ │ Right (Ty (TPair % % @ @ (Ty TKey :) (Ty (TPair % % @ @ (Ty TKey :) (Ty (TMap (Ty (TPair % % @ @_ (Ty TInt :) (Ty (TPair % % @ @ (Ty TInt :) (Ty TInt :)) :)) :) (Ty TKey :)) :)) :)) :)
┃ │ ━━━ Intermediate ━━━
┃ │ ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "pair"
┃ │ , mpaArgs =
┃ │ [ ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "key"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ , ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "key"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ , ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "map"
┃ │ , mpaArgs =
┃ │ [ ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "pair"
┃ │ , mpaArgs =
┃ │ [ ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "int"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ , ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "int"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ , ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "int"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ ]
┃ │ , mpaAnnots = []
┃ │ }
┃ │ , ExpressionPrim
┃ │ MichelinePrimAp
┃ │ { mpaPrim = MichelinePrimitive "key"
┃ │ , mpaArgs = []
┃ │ , mpaAnnots = []
┃ │ }
┃ │ ]
┃ │ , mpaAnnots = []
┃ │ }
┃ │ ]
┃ │ , mpaAnnots = []
┃ │ }
┃ │ ━━━ Roundtrip ━━━
┃ │ Right (Ty (TPair % % @ @ (Ty TKey :) (Ty (TPair % % @ @ (Ty TKey :) (Ty (TMap (Ty (TPair % % @ @ (Ty TInt :) (Ty (TPair % % @ @ (Ty TInt :) (Ty TInt :)) :)) :) (Ty TKey :)) :)) :)) :)
This failure can be reproduced by running:
> recheck (Size 89) (Seed 8242240008194861097 6711805387412283887) Ty
Use '--hedgehog-replay "Size 89 Seed 8242240008194861097 6711805387412283887"' to reproduce.
Use -p '/Roundtrip expression.Ty/' to rerun this test only.
Steps to reproduce
cabal run morley-test -- --hedgehog-replay "Size 89 Seed 8242240008194861097 6711805387412283887" -p '/Roundtrip expression.Ty/'
Environment
- 6eb73a0c (current master)