hello list,

loading the code below into ghci gives me this error:

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 HttpRequest and HttpResponse constructors of HttpMessage as I've sketched out an action that might return either one. Given that I thought what I was doing below was defining these as type constructors (maybe I have my vocabulary mixed up) I don't know why ghci is returning this error.


module HttpMessage ( HttpMessage(..), HttpRequestMethod(..), cookie ) where

import Data.Map as M

data HttpHeaders = HttpHeaders !(M.Map String String )
data HttpMessage =
   HttpRequest {
       headers        :: HttpHeaders,
       body           :: String,
       request_method :: HttpRequestMethod,
       uri            :: URI,
       http_version   :: Float,
       cookies        :: !(M.Map String String)
   }
   | HttpResponse {
       headers        :: HttpHeaders,
       body           :: String,
       status         :: HttpStatus
   }

data HttpRequestMethod = Get | Head | Post | Put | Delete | Unsupported String
data HttpStatus = OK | NotFound | NotAuthorized | ServerError

data URI = URI {
   protocol :: String,
   domain   :: String,
   port     :: String,
   path     :: String,
   query    :: !(M.Map String String),
   anchor   :: String
}

cookie :: String -> HttpRequest -> Maybe String
cookie n request = M.lookup n (cookies request)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to