I have wrapped up whole data family in a single existential:
data Type = Numeric | Boolean
data family Operator (t :: Type)
data instance Operator 'Numeric = Add | Sub
data instance Operator 'Boolean = And | Or
data AnyOp where
AnyOp :: Operator t -> AnyOp
Now I would like to do some pattern matching on it
pp :: AnyOp -> String
pp op = case op of
AnyOp Add -> "+"
AnyOp Sub -> "-"
AnyOp And -> "&"
AnyOp Or -> "|"
But the typechecker yells at me because
âtâ is a rigid type variable bound by a pattern with constructor: AnyOp :: forall (t :: TType). Operator t -> AnyOp, in a case alternative at somesource/somefile/someposition Expected type: Operator t Actual type: Operator 'Boolean ```
Why? What is the proper way of doing this?