Open nikivazou opened 7 years ago
We can rewrite the cast back to constructor application and case analysis, this is what I do for single-method classes.
We meaning a function we define in Liquid Haskell? Or can we just disable a simplification pass of ghc?
I mean rewrite the Core from
foo `Cast` Foo ~ Wrap Foo
to
Wrap foo
and vice versa for unwrapping.
Yes, LH would do this behind the scenes
Oh interesting idea! It should be though that a ghc transformation step does exactly the inverse! If we could deactivate it...
Not necessarily, it may be baked into the desugaring step
See
for the code that already does this transformation for type classes.
If you defined a data type to wrap a value
Liquid Haskell will automatically turn
unwrap
into a measure.Thus, just opening
Wrap
is enough (using the measure info) to prove the following equalityIf
Wrap
was a newtype,Wrap
does not exist in core, instead, ghc is using casts to implement the above casting. The question is how can we prove theoremwrapTheorem
ifWrap
is defined to be a newtype, thus no measure definition is possible?