-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
• Couldn't match type ‘'False’ with ‘'True’ #4
Comments
This is a known issue if you have too many constructors. Can you write a manual instance for PrimOp via the Word16 instance? Not via generics. EDIT: @chrisdone I want to expand a bit on my comment. I tend to close this issue as wontfix, since it is only triggered by the uncommon case of ADTs with more than 256 constructors. This is due to encoding of the tag as 8 bit. In this case of an enum ADT the solution is manual encoding via Word16. instance Persist PrimOp where
put = put @Word16 . fromIntegral . fromEnum
get = do
x <- toEnumMay . fromIntegral <$> get @Word16
maybe (fail "Invalid PrimOp") pure x Please let me know if it is ok for you like this. I think persist is a good solution for your problem. It is as simple and small as things can get, like a stripped down store and faster compilation than flat, which focuses more on compact bitwise packing. More problematic cases would involve ADTs, which are not enums, with more than 256 constructors. For those it would be worth fixing the issue to take advantage of generics. |
Thanks @minad. Good to know. |
@minad Note that it is possible to have better error messages for this - see discussion here and patch here. |
@mgsloan Thanks! I will add this! |
Hey,
I thought you might find this error message interesting if not helpful:
I'm gonna try the
flat
package, as I really just want a trivial serialization that's more efficient thanbinary
and doesn't take 10 minutes to build likestore
. 🤷♂️Here's a gist with a reproducible case:
https://gist.github.com/chrisdone/c908dbdbbeaaa945575ce5be7b47b9a6
I was deriving the type with TH (commented out), but it's reproducible with the derived sum type copy/pasted in.
Good luck! 👍 😄
The text was updated successfully, but these errors were encountered: