[Haskell-cafe] How to match on such type

Baa aquagnu at gmail.com
Tue Dec 5 10:47:48 UTC 2017


Hello, All!

I have type:

  infixr 9 |||
  data a ||| b = A a|B b deriving (Eq, Data, Show)

and usually I wraps into it values which are instances of my class
IsTag:

  class IsTag a where
    anyTag :: a

So, I need to check if some value wrapping by `a|||b` is equal to
`anyTag`, i.e.:

  A (B (A x)) == (anyTag::TypeOf_x)
  ==> True

This function must be generic, ie, it can not know anything about
concreate TypeOf_x, only: `a|||b` and `IsTag`. How to do it???

I added `Data` to `a|||b` and even to values which I "wrap" with
`a|||b` (I assumed to use `gmap*` and Co), but this does not help me.
Is it even possible??

==
Best regadrs, Paul



More information about the Haskell-Cafe mailing list