[Haskell-beginners] trouble using the foldl ....

Daniel Fischer daniel.is.fischer at googlemail.com
Thu Aug 11 13:07:42 CEST 2011


On Thursday 11 August 2011, 12:53:16, Sunil S Nandihalli wrote:
> Hello everybody,
> When I compile a file containing ...
> I get the following error..
> 
> main.hs:34:107:
>     Couldn't match expected type `Bool' with actual type `Maybe t0'
>     In the pattern: Just v
>     In a case alternative: (Just v) -> ("." ++ (show v) ++ ".")
>     In the second argument of `(++)', namely
>       `(case (M.member (newRowId, newColId) locsmap) of {

`member'  tests whether a key is in the map, it returns a Bool ("is it a 
member", not "give me the member if there is one").
It looks like you want M.lookup here.

>           (Just v) -> ("." ++ (show v) ++ ".")
>           (Nothing) -> "   " })'
> 
> can somebody help?
> 
> Thanks,
> Sunil.




More information about the Beginners mailing list