Is it possible to implement a type class as follows:
class SomeClass e where isEq :: (SomeClass e') => e -> e' -> Bool
where isEq xy will return true when x and y are the same instances of this type class?
Context. This is a finely veiled attempt to get runtime type tests. Although I first read that Haskell has type erasure, I also read that with recent extensions for GHC there is some runtime information.
edit: for those who are wondering about my usecase ... I used level-level programming to provide certain properties of some of my ADTs, namely resource utilization. These resources are represented by various types (and resource locks are respectively implemented at the type level).
I am trying to write an optimization procedure requiring identification of write / read resources. But since all my resources are represented by separate singletones, the only common factor (except for all values that are the bottom) is the type that groups them together.
In a nutshell, I want to use the results of my programming at the level of the runtime level value.
source share