저는 방금 Yesod를 시작하고 서버에서 작은 CSS 파일을 제공하려고합니다.Yesod 012에서 CSS 문서 검색
나는 원래 쓴 : 나에게 다음과 같은 유형의 오류를 제공
getMainStyleR :: Handler HTML
getMainStyleR = [cassius|
#main
color: 333333
font-family: Sans
|]
을 : CSS는 HTML되지 않기 때문에
Couldn't match expected type `t0
-> shakespeare-css-1.0.7.1:Text.Css.Css'
with actual type `HandlerT HelloWorld IO Html'
내가 생각? 이게 옳은 거니? 내가
Couldn't match expected type `HandlerT site0 IO res0'
with actual type `t0 -> shakespeare-css-1.0.7.1:Text.Css.Css'
를 얻을 수 (하스켈이 추론을 확인하기 위해) getMainStyleR의 유형 선언을 가지고가는 경우에
이 그렇다면, 그래서 핸들러는 HTML을 부여 할 필요가 있다고 생각, 그래서 내가 할 일을 CSS를 만들고 싶다면?
나는 짐작 :
getMainStyleR :: Handler Css
getMainStyleR = [cassius|
#main
color: 333333
font-family: Sans
|]
하지만 그건 그냥 말한다 :
Not in scope: type constructor or class `Css'
CSS의 덩어리를 반환하는 유형이 있습니까?
나는 아래 @Michael Snoyman의 제안을 시도 :업데이트 (물건의 종류는 어떤 점에서 필요 해요 것 같다). 먼저 간단한 부분 응답
No instance for (ToTypedContent Css)
arising from a use of `yesodRunner'
Possible fix: add an instance declaration for (ToTypedContent Css)
In the expression: yesodRunner getMainStyleR
In the expression:
((Data.Text.Encoding.encodeUtf8 . Data.Text.pack) "GET",
yesodRunner getMainStyleR)
In the first argument of `containers-0.5.0.0:Data.Map.Base.fromList', namely
`[((Data.Text.Encoding.encodeUtf8 . Data.Text.pack) "GET",
yesodRunner getMainStyleR)]'
감사 :
하면 해당 함께, 당신의 핸들러 함수가 같이 보일 것이다 퍼팅. 그게 더 나를 필요로하지만 프레임 워크에서 더 깊은 문제를 일으킨 것 같습니다. 새로운 질문으로 주요 질문을 업데이트했습니다. 어떤 아이디어? – interstar
그저 누락 된 인스턴스 선언 일뿐입니다. 이런 방식으로 CSS를 제공하기 전에 누군가가 실제로 나서지 않습니다. 나는 [yesod-core 1.2.11에 해당 인스턴스를 추가했습니다.] (https://github.com/yesodweb/yesod/commit/7512cc2bfc6e10985abd066c3175b0890e4073d0) –
Thanks @Michael Snoyman. 미안하지만, Yesod 탐험으로 돌아갈 기회가 없었지만 이번 주에 시도 할 것입니다. – interstar