Dear Brandon, Ozgur, et al,

Thanks very much for you explanation. This seems to be a perfectly reasonable 
explanation; the wrapper-types I used probably explicitly invoke typeOf with 
undefined. The problem here, however, is that in my actual program, I don't use 
ADTs, but I use GADTs, so as to carry the context (Monad, Typeable1) with the 
constructor. To get to this context, I must pattern-match with the constructor. 
It seems hiding contexts (which I really like about GADTs) isn't "available" 
consistently. Oh well ;)

Regards,
Philip


On 29 Aug 2011, at 01:20, Brandon Allbery wrote:

On Sun, Aug 28, 2011 at 18:44, Philip Holzenspies 
<p...@st-andrews.ac.uk<mailto:p...@st-andrews.ac.uk>> wrote:
instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
       typeOf t@(MyADT _)

typeOf is usually invoked with an undefined parameter; it should use types, 
never values.  Here you've defined it to deconstruct what it's passed, which 
means that anything that uses it in the usual way (`typeOf (undefined :: 
someType)') will immediately throw undefined.

You don't need a deconstructor there; you (correctly) throw away the value, and 
it doesn't provide any type information not already available from the instance 
declaration.  `typeOf t' should be good enough.

--
brandon s allbery                                      
allber...@gmail.com<mailto:allber...@gmail.com>
wandering unix systems administrator (available)     (412) 475-9364 vm/sms


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to