[Haskell-cafe] type constructor confusion

Stephen Howard stephen at enterity.com
Wed Jun 18 22:02:27 EDT 2008


Thanks Brandon, forgot to send my reply to the list:

Ok, so I am confusing things.  Good to know.  So my question is how do I 
fulfill this scenario?

- I have an action that might return either an HttpResponse or an 
HttpRequest, depending on if the IO in the action determined more work 
needed doing.  It's here, though I doubt it's "correct" yet:

requestHandler :: HttpRequest -> IO HttpResponse
requestHandler request = do
   session <- sessionHandler request
   ret     <- uriHandler     request
   case ret of
       HttpResponse -> ret
       HttpRequest  -> resourceHandler session ret

uriHandler :: HttpRequest -> IO HttpMessage
sessionHandler :: HttpRequest -> IO HttpSession

I've given the uriHandler a signature of IO HttpMessage because the 
HttpMessage might be either an HttpResponse or an HttpRequest, and I 
don't know how I should be specifying that.  Ideas?

- Stephen

Brandon S. Allbery KF8NH wrote:
>
> On Jun 18, 2008, at 15:31 , Stephen Howard wrote:
>
>> HttpMessage.hs:36:20: Not in scope: type constructor or class 
>> `HttpRequest'
>>
>> The troublesome line is the definition of the cookie function at the 
>> end of the code.  I've made
>
> Right.  "HttpRequest" is a data constructor associated with the type 
> constructor "HttpMessage".
> (Data constructors are effectively functions; you used it in the 
> context of a type, not a function name.)
>


More information about the Haskell-Cafe mailing list