id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
4355,"Coud not deduce (Typeable a) from context (Typeable a, …)",maltem,simonpj,"Attached is a module containing code from XMonadContrib that does not type-check anymore with ghc 7.0.1 rc1. I tried to strip the code somewhat down; at least it only depends on base and mtl. Here's the (somewhat irritating) error message:

{{{
tcBug.hs:50:30:
    Could not deduce (Typeable a)
      from the context (Typeable a, Show ts, HList ts a, LayoutClass l a)
      arising from a use of `fromMessage'
    Possible fix:
      add (Typeable a) to the context of the instance declaration
    In a stmt of a pattern guard for
                 an equation for `handleMessage':
        Just (Toggle t) <- fromMessage m
    In an equation for `handleMessage':
        handleMessage mt m
          | Just (Toggle t) <- fromMessage m,
            i@(Just _) <- find (transformers mt) t
          = case currLayout mt of {
              EL l det
                -> do { l' <- fromMaybe l
                            `fmap`
                              handleMessage l (SomeMessage ReleaseResources);
                        .... }
                where
                    cur = (i == currIndex mt) }
          | otherwise
          = case currLayout mt of {
              EL l det
                -> fmap (fmap (\ x -> mt {currLayout = EL x det}))
                 $ handleMessage l m }
    In the instance declaration for `LayoutClass (MultiToggle ts l) a'

tcBug.hs:51:25:
    Could not deduce (HList ts a)
      from the context (Typeable a,
                        Show ts,
                        HList ts a,
                        LayoutClass l a,
                        Transformer t a)
      arising from a use of `find'
    Possible fix:
      add (HList ts a) to the context of
        the data constructor `Toggle'
        or the instance declaration
    In a stmt of a pattern guard for
                 an equation for `handleMessage':
        i@(Just _) <- find (transformers mt) t
    In a stmt of a pattern guard for
                 an equation for `handleMessage':
        Just (Toggle t) <- fromMessage m
    In an equation for `handleMessage':
        handleMessage mt m
          | Just (Toggle t) <- fromMessage m,
            i@(Just _) <- find (transformers mt) t
          = case currLayout mt of {
              EL l det
                -> do { l' <- fromMaybe l
                            `fmap`
                              handleMessage l (SomeMessage ReleaseResources);
                        .... }
                where
                    cur = (i == currIndex mt) }
          | otherwise
          = case currLayout mt of {
              EL l det
                -> fmap (fmap (\ x -> mt {currLayout = EL x det}))
                 $ handleMessage l m }
}}}
",bug,closed,high,7.0.1,Compiler (Type checker),7.1,fixed,,,Unknown/Multiple,Unknown/Multiple,None/Unknown,,typecheck/should_compile/T4355,,,
