I have a custom value type Value labeled by its type ValType:
data ValType
= Text
| Bool
data Value (tag :: ValType) where
T :: Text -> Value 'Text
B :: Bool -> Value 'Bool
and I would like to define a function that unwraps an existentially quantified Value, that is it should have the following type signature:
data SomeValue = forall tag. SomeValue (Value tag)
unwrap :: SomeValue -> Maybe (Value tag)
I can define unwrap for 'Bool and 'Text separately, but how do I define a polymorphic unwrap?