I am a Haskell newbie.

I am trying to write a small Webdav server using the Yesod Framework and modelled after the WebdavServlet in the Apache Tomcat 7 source code. I have run into a problem returning an error from one of my functions.

My webdav service should return either XML or JSON, depending on the value of the Accept header sent in by the caller. I defined a data type called RepXmlJson:

import Yesod

data RepXmlJson = RepXmlJson RepXml RepJson

instance HasReps RepXmlJson where
  chooseRep (RepXmlJson (RepXml xml) (RepJson json)) = chooseRep
    [ (typeXml, xml)
    , (typeJson, json)
    ]

I am using this data type as the return value of my services, specifically the lockWebdavR function. I am trying to return a status 423 (locked) if a resource is currently locked. My code looks like this:

import qualified Data.ByteString as B
import qualified Data.Map        as M
import qualified Data.Text       as T
import qualified Network.Wai     as W

mkYesodSub "Webdav" [] [parseRoutes|
  / WebdavR COPY DELETE LOCK MKCOL MOVE OPTIONS PROPFIND PROPPATCH PUT UNLOCK
|]

type WebdavHandler yesod = GHandler Webdav yesod

webdavLocked423 :: Status
webdavLocked423 = Status 423 "Locked"

isLockedRequest :: Yesod master => Request -> WebdavHandler master Bool
-- isLockedRequest definition omitted for brevity

lockWebdavR :: Yesod master => WebdavHandler master RepXmlJson
lockWebdavR = do
  request <- getRequest
  locked <- isLockedRequest request
  if locked
    then return $
      W.responseLBS webdavLocked423 [("Content-Type", "text/plain")] ""
    else return undefined

I am getting the following error:

Webdav.hs:94:10:
    C
Edit
Report