Re: Type checking/inference

2003-12-28 Thread s_mazanek
Hi,

 prelude :t map (foldr filter)
 map (foldr filter) :: [[a]] - [[a - Bool] - [a]]
 
 Two main questions:
 1/ How does hugs derive this answer?
 2/ What input can I give so that it yields a correct result? I've tried 
 giving it a list of lists but it fails...

Try:

map (flip (foldr filter) [even,odd]) [[1,2,3],[4,5,6]]

I guess this meets your expectation.

Without flipping the arguments:
Prelude map (foldr filter [1,2,3]) [[even]]
[[2]]
Prelude map (foldr filter [1,2,3]) [[even],[even,odd]]
[[2],[]]
Prelude map (foldr filter [1,2,3]) [[even],[even,odd],[odd]]


Bye,
Steffen
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Type errors in Haskell programming languages - Plz help

2003-11-05 Thread s_mazanek
Hello.
 
  The code is as follows - 
  -- Code starts --
  entry :: [Char] - [(Char,Int)]
  entry list = do t - getGroups list
  mergeGroups t
  
  getGroups   :: [Char] - [(Char,Int)]
  mergeGroups :: [(Char,Int)] - [(Char,Int)]
  -- Code Ends -- 

 You probably mean:

 entry list = let t = getGroups list in mergeGroups t

 or simpler

 entry = mergeGroups . getGroups

 Take a look at the instance Monad [ ] in the Prelude to
 see, why your program does not work.

 Ciao,
 Steffen

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe