Hi,<br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 11:21 PM, TP <span dir="ltr"><<a href="mailto:paratribulations@free.fr" target="_blank">paratribulations@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">José Pedro Magalhães wrote:<br>
<br>
>> Oh, it should probably be simply<br>
>><br>
>> deriving instance Typeable 'Zero<br>
>> deriving instance Typeable 'Succ<br>
>><br>
><br>
> Yes, that's how it should be. Please let me know if that<br>
> doesn't work.<br>
<br>
</div>Thanks, it works perfectly like that.<br>
I don't understand exactly why the previous syntax did not work, but maybe<br>
it will be clearer when I finish the paper "Scrap your boilerplate: a<br>
practical design pattern for generic programming" (anyway, this paper seems<br>
very interesting).<br></blockquote><div><br>It's an interesting paper, but I'm afraid it won't help you understand what's going<br>on. Typeable is changing in GHC 7.8 to become poly-kinded. You are using<br>
Typeable instances for things which are not of kind *, so you need this new<br>poly-kinded variant. The SYB paper says nothing about polykinds (it was written<br>way before polykinds came up).<br><br>You can find some more information on the new Typeable here:<br>
<a href="http://hackage.haskell.org/trac/ghc/wiki/GhcKinds/PolyTypeable">http://hackage.haskell.org/trac/ghc/wiki/GhcKinds/PolyTypeable</a><br><br>By the way, you can also get those Typeable instances derived automatically<br>
if you use the LANGUAGE pragma AutoDeriveTypeable. This is also documented<br>in the HEAD user's guide.<br><br><br>Cheers,<br>Pedro<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Output of the code:<br>
<br>
---------------------<br>
$ runghc-head test_typeable.hs<br>
Box test_typeable.hs: Prelude.undefined<br>
---------------------<br>
<br>
Maybe the "Box " in front of the line is strange, but it is OK: "one" is<br>
undefined, not "Box one".<br>
<br>
This is the full tested code, for sake of reference:<br>
<br>
-----------------------<br>
<div class="im">{-# LANGUAGE GADTs #-}<br>
{-# LANGUAGE DeriveDataTypeable #-}<br>
{-# LANGUAGE DataKinds #-}<br>
{-# LANGUAGE PolyKinds #-}<br>
{-# LANGUAGE StandaloneDeriving #-}<br>
<br>
import Data.Typeable<br>
<br>
data Nat = Zero | Succ Nat<br>
</div> deriving ( Show, Eq, Ord )<br>
<div class="im"><br>
deriving instance Typeable 'Zero<br>
deriving instance Typeable 'Succ<br>
<br>
</div><div class="im">data Box where<br>
Box :: (Typeable s, Show s, Eq s) => s -> Box<br>
deriving Typeable<br>
<br>
</div>data Proxy a = P deriving (Typeable, Show, Eq)<br>
<div class="im"><br>
deriving instance Show Box<br>
instance Eq Box where<br>
<br>
(Box s1) == (Box s2) = Just s1 == cast s2<br>
<br>
main = do<br>
<br>
let one = undefined :: Main.Proxy ('Succ 'Zero)<br>
let foo = Box one<br>
print foo<br>
</div>----------------------<br>
<br>
Thanks a lot,<br>
<br>
TP<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>