#1776: type families : couldn't match type "Elem a" against type "Elem a"
-----------------------+----------------------------------------------------
  Reporter:  guest     |          Owner:         
      Type:  bug       |         Status:  new    
  Priority:  normal    |      Milestone:         
 Component:  Compiler  |        Version:  6.8    
  Severity:  normal    |       Keywords:         
Difficulty:  Unknown   |             Os:  Unknown
  Testcase:            |   Architecture:  Unknown
-----------------------+----------------------------------------------------
 I received the error

 {{{
 GHCi, version 6.8.0.20071012: http://www.haskell.org/ghc/  :? for help
 Loading package base ... linking ... done.
 [1 of 1] Compiling Test             ( Test.hs, interpreted )

 Test.hs:17:27:
     Couldn't match expected type `Elem a'
            against inferred type `Elem a'
       Expected type: Elem a -> Maybe (Elem a) -> Maybe (Elem a)
       Inferred type: Elem a -> Maybe (Elem a) -> Maybe (Elem a)
     In the first argument of `foldr', namely `mf'
     In the second argument of `fromMaybe', namely
         `(foldr mf Nothing xs)'
 Failed, modules loaded: none.
 }}}

 when running the following module in GHCi:

 {{{
 {-# LANGUAGE TypeFamilies #-}

 module Test where

 import qualified Prelude as P
 import Prelude hiding (foldr, foldr1)

 import Data.Maybe

 type family Elem a

 class Foldable a where
     foldr :: (Elem a -> b -> b) -> b -> a -> b

     foldr1 :: (Elem a -> Elem a -> Elem a) -> a -> Elem a
     foldr1 f xs = fromMaybe (error "foldr1: empty structure")
                     (foldr mf Nothing xs)
        where mf x Nothing  = Just x
              mf x (Just y) = Just (f x y)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1776>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to