[Haskell-cafe] GADTs, type classes, existentials

Dan Doel dan.doel at gmail.com
Sun May 6 10:05:25 EDT 2007


On Sunday 06 May 2007, Mike Hamburg wrote:
> data MetaMap k v where
>     Map  :: Ord k => Map.Map k v -> MetaMap k v
>     Cat  :: MetaMap k1 (MetaMap k2  v) -> MetaMap (k1,k2) v
>     {- other, similar constructors -}
>
> lookup :: Monad m => k -> MetaMap k v -> m v
> lookup k (Map  m) = Map.lookup k m
> lookup k (Cat  m) = case k of (k1,k2) -> lookup k1 m >>= lookup k2


What version of ghc are you using?

The snippet works here, but I believe that GADTs only store the Ord dictionary 
as is needed here in HEAD. It won't work if you're trying to do this with 
6.6.

-- Dan Doel


More information about the Haskell-Cafe mailing list