[Haskell-cafe] casting
Thomas Conway
drtomc at gmail.com
Mon Oct 9 07:47:05 EDT 2006
Hi All
I'm having some difficulty with typeclasses.
What I'm trying to do should be obvious, but it's still giving me
trouble. I want to take a packaged item, and strengthen the
constraints on its type. Rather than being just any type that is an
instance of A, I want to do a runtime check and do something different
if it is a type that is also an instance of B (which implies that it
is an instance of A also).
I've attached some code that attempts this, but ghci (er, 6.4.2 with
-fglasgow-exts) complains:
Compiling Main ( Cast.hs, interpreted )
Cast.hs:15:22:
Ambiguous type variable `b' in the constraint:
`B b' arising from use of `qux' at Cast.hs:15:22-24
Probable fix: add a type signature that fixes these type variable(s)
Failed, modules loaded: none.
So, can anyone suggest how I can achieve my goal?
thanks,
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cast.hs
Type: application/octet-stream
Size: 268 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20061009/22d7b1fa/Cast.obj
More information about the Haskell-Cafe
mailing list