[Haskell-cafe] type hackery question
mutjida at gmail.com
Sun Dec 17 21:27:01 EST 2006
Thanks for the response.
> > Is it possible to write a class which checks to see if two given type
> > arguments are unifiable?
> This will probably help:
> That was Oleg's response to a post of mine:
I don't think either of these approaches really accomplishes what I'm
after since they both require both arguments to be instantiated
(correct me if I'm wrong about this). I would like a TypeCastP class
for which I can write something like:
instance (TypeClassP xs (HCons targ rest) b, Branch b targ rest)
=> Member targ xs
where Member can used to build the expected list via unification
(similar to Prolog) as well as check membership in an already
instantiated list. I was thinking of trying to use Oleg's explicit
backtracking machinery (http://okmij.org/ftp/Haskell/poly2.hs) to get
backtracking based on unification failure. Also, I was hoping to do
this with Haskell's type variables and unification, rather than
encoding my own machinery.
I'm beginning to think what I'm after is not possible...
More information about the Haskell-Cafe