f(g(x), h(y)) - Correct syntax

Hallo! I have this code: ---------------------------------------- q1 :: EName -> [ApprenticeInfo] q1 c = [apprenticeInfo n | n <- allApprentices, member ((sq4 c) (firstOf5(n))) == True] sq4 :: ESurname -> [IDB] sq4 c = (sq3 (sq1 (c))) firstOf5 :: (a,b,c,d,e) -> a firstOf5 (n,_,_,_,_) = n member :: [IDB] -> IDB -> Bool member [] y = False member(x:xs) y = (x==y) || member xs y ---------------------------------------- sq4 works correctly and returns [IDB] Unfortunately member ((sq4 c) (firstOf5(n))) gives this error: Type error in application *** Expression : sq4 c (firstOf5 n) *** Term : sq4 *** Type : ESurname -> [IDB] *** Does not match : a -> b -> c As far as I see it I'm not writing the correct syntax for a function of 2 functions. I have g(x): Esurname->[IDB] h(y): (IDB,_,_,_,_) -> IDB f(x,y): ([IDB], IDB) -> Bool I want to obtain f(g(x), h(y)) and I obtain something else. Where am I wrong? Thanks

On Feb 11, 2008 2:27 PM, news@lyra.net
Hallo!
I have this code: ---------------------------------------- q1 :: EName -> [ApprenticeInfo] q1 c = [apprenticeInfo n | n <- allApprentices, member ((sq4 c) (firstOf5(n))) == True]
sq4 :: ESurname -> [IDB] sq4 c = (sq3 (sq1 (c)))
firstOf5 :: (a,b,c,d,e) -> a firstOf5 (n,_,_,_,_) = n
member :: [IDB] -> IDB -> Bool member [] y = False member(x:xs) y = (x==y) || member xs y ---------------------------------------- sq4 works correctly and returns [IDB] Unfortunately member ((sq4 c) (firstOf5(n))) gives this error:
Type error in application *** Expression : sq4 c (firstOf5 n) *** Term : sq4 *** Type : ESurname -> [IDB] *** Does not match : a -> b -> c
As far as I see it I'm not writing the correct syntax for a function of 2 functions.
I assume you meant arguments. And you're right. In Haskell the whole argument list is not enclosed in parentheses like it is in many other languages. "f (x y)" means what C would call "f(x(y))", whereas "f x y" means what C would call "f(x,y)" (modulo currying stuff). Drop the set of parentheses starting just after member and you should be fine. Luke

On Mon, 11 Feb 2008, news@lyra.net wrote:
Hallo!
I have this code: ---------------------------------------- q1 :: EName -> [ApprenticeInfo] q1 c = [apprenticeInfo n | n <- allApprentices, member ((sq4 c) (firstOf5(n))) == True]
sq4 :: ESurname -> [IDB] sq4 c = (sq3 (sq1 (c)))
firstOf5 :: (a,b,c,d,e) -> a firstOf5 (n,_,_,_,_) = n
member :: [IDB] -> IDB -> Bool member [] y = False member(x:xs) y = (x==y) || member xs y
cf. List.elem
participants (3)
-
Henning Thielemann
-
Luke Palmer
-
news@lyra.net