
You can define a view viewGlobalRef :: GlobalRef s -> Either InstanceName (GlobalRef s') viewGlobalRef FromIntegerGlobal = Right FromIntegerGlobal viewGlobalRef FromDecimalGlobal = Right FromDecimalGlobal viewGlobalRef (InstanceGlobal name) = Left name but that loses the `s ~ Resolved` information in the `InstanceGlobal` case, so I'd define and use matchGlobalRef :: GlobalRef s -> (s ~ Resolved => InstanceName -> r) -> (forall s'. GlobalRef s' -> r) -> r matchGlobalRef globalRef handleInstanceGlobal handleOther = case globalRef of FromIntegerGlobal -> handleOther FromIntegerGlobal FromDecimalGlobal -> handleOther FromDecimalGlobal InstanceGlobal name -> handleInstanceGlobal name