[Haskell-cafe] expected vs inferred type confusion

Bayley, Alistair Alistair.Bayley at invesco.com
Mon Jun 23 11:19:04 EDT 2008


> From: haskell-cafe-bounces at haskell.org 
> [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Stephen Howard
> 
> the error:
> 
> renao.hs:6:4:
>     Couldn't match `HttpResponse' against `IO HttpResponse'
>       Expected type: IO HttpResponse
>       Inferred type: IO (IO HttpResponse)
>     In the expression: return $ (handler session request)
>     In the result of a 'do' expression: return $ (handler 
> session request)
> 
> the code:
> 
> import HttpMessage
> import HttpSession
> 
> resourceHandler :: HttpSession -> HttpRequest -> IO HttpResponse
> resourceHandler session request = do
>     return $ handler session request
>     where
>         handler = which_handler request
>         which_handler r = case request_method r of
>             Get    -> get_resources
>             Head   -> last_modified
>             Post   -> update_resources
>             Put    -> create_resources
>             Delete -> delete_resources
> 
> 
> get_resources :: HttpSession -> HttpRequest -> IO HttpResponse
> get_resources session request = undefined
> 
> -- ... the same stubbed definition for the other handlers 
> (last_modified, etc)


Try removing the do ... return $  e.g.

> resourceHandler session request =
>     handler session request
>     where

Alistair
*****************************************************************
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*****************************************************************



More information about the Haskell-Cafe mailing list