Update Trac ticket URLs to point to GitLab
[ghc.git] / testsuite / tests / typecheck / should_compile / FD2.hs
1 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
2 {-# LANGUAGE ScopedTypeVariables, FlexibleContexts #-}
3
4 -- #1783
5 -- Like #1781 you could argue that this one should succeed
6 -- but we stick with the old behaviour for now. When we do
7 -- fundeps properly it'll probably start to work
8
9 module ShouldCompile where
10
11 import Prelude hiding (foldr, foldr1)
12
13 import Data.Maybe
14
15 class Elem a e | a -> e
16
17 class Foldable a where
18 foldr :: Elem a e => (e -> b -> b) -> b -> a -> b
19
20 -- foldr1 :: forall e. Elem a e => (e -> e -> e) -> a -> e -- WORKS!
21 foldr1 :: Elem a e => (e -> e -> e) -> a -> e
22 foldr1 f xs = fromMaybe (error "foldr1: empty structure")
23 (foldr mf Nothing xs)
24 where mf :: Elem a e => (e -> Maybe e -> Maybe e)
25 mf x Nothing = Just x
26 mf x (Just y) = Just (f x y)