2014-08-31 1 views
1

주어진 this 작은 프로젝트 내가 하스켈을 배우기 위해 사용하고 있는데, 요청 처리기의 코드 생성을 햄릿 템플릿으로 옮기고 싶지만, 물건을 전달하는 방법을 모르겠다.햄릿의 스냅 렌더리스트

 
Couldn't match expected type `String -> String' 
       with actual type `String' 
    In the return type of a call of `renderHtml' 
    Probable cause: `renderHtml' is applied to too many arguments 
    In the expression: renderHtml ($ (shamletFile "fileList.hamlet")) 
    In an equation for `myTemplate': 
     myTemplate = renderHtml ($ (shamletFile "fileList.hamlet")) 

코드 :

site :: Snap() 
site = 
    ifTop (writeBS "hello world") <|> 
    route [ ("foo", writeBS "ba"), 
      ("view_root_json_files", listRootFilesHandler) 
      ] <|> 
    dir "static" (serveDirectory ".") 

--myTemplate :: String -> String 
--myTemplate = renderHtml ($(shamletFile "fileList.hamlet")) 

toText :: [FilePath] -> Text 
toText = foldMap (flip snoc '\n' . pack) 

listRootFilesHandler :: Snap() 
listRootFilesHandler = do 
    filenames <- liftIO $ getDirectoryContents "data" 
    let filtered_filenames = filter (not . isPrefixOf ".") filenames 
    writeText $ toText filtered_filenames 

답변

2

GHC하는 당신에게 올바른 유형의 서명을 말하고있는 것은 넣어

내 현재 코드는 선이 처음 차단제 인 주석이있는 다음과 같은 오류가 발생합니다 그곳에. String -> StringString으로 바꿉니다.