type families : couldn't match type "Elem a" against type "Elem a"
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)
Trac metadata
Trac field | Value |
---|---|
Version | 6.8 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | aslatter@gmail.com |
Operating system | Unknown |
Architecture | Unknown |