Created
October 12, 2011 22:14
-
-
Save esehara/1282809 to your computer and use it in GitHub Desktop.
なぞのエラー
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, | |
| TemplateHaskell, OverloadedStrings #-} | |
| import Yesod | |
| import Yesod.Auth | |
| import Yesod.Auth.OAuth | |
| import Data.Text.Internal | |
| data HelloWorld = HelloWorld | |
| mkYesod "HelloWorld" [parseRoutes| | |
| / HomeR GET | |
| /user/#String/ UserHomeR GET | |
| |] | |
| instance Yesod HelloWorld where | |
| approot _ = "" | |
| getHomeR :: Handler RepHtml | |
| getHomeR = defaultLayout $ do html_header | |
| html_header = [whamlet|<h1>Simple Code Book</h1>|] | |
| html_breadload userid = [whamlet|<a href=@{HomeR}>Simple Code Book</a> -> #{userid} |] | |
| getUserHomeR :: String -> Handler RepHtml | |
| getUserHomeR userid = defaultLayout $ | |
| do html_header | |
| html_breadload userid | |
| consumerKey :: String | |
| consumerKey = "hogehoge" | |
| consumerSecret :: String | |
| consumerSecret = "fugafuga" | |
| twittername :: AuthPlugin m -> String | |
| twittername (AuthPlugin name dispatch login) = showText $ name | |
| twitter :: YesodAuth a => AuthPlugin a | |
| twitter = authTwitter consumerKey consumerSecret | |
| {- | |
| YesodAuth a を抜くと下のようなエラー。エラーの意図がよくわからない。 | |
| No instance for (YesodAuth m0) | |
| arising from a use of `authTwitter' | |
| In the expression: authTwitter consumerKey consumerSecret | |
| In an equation for `twitter': | |
| twitter = authTwitter consumerKey consumerSecret | |
| -} | |
| -- html_login = [whamlet|#{get_name $ twitter}|] | |
| {- | |
| 上を追加すると、下のようなエラー | |
| Ambiguous type variable `m1' in the constraint: | |
| (YesodAuth m1) arising from a use of `twitter' | |
| Probable fix: add a type signature that fixes these type variable(s) | |
| In the first argument of `get_name', namely `twitter' | |
| In the first argument of `toHtml', namely `get_name twitter' | |
| In the first argument of `addHtml', namely | |
| `toHtml (get_name twitter)' | |
| -} | |
| main :: IO () | |
| main = warpDebug 3000 HelloWorld |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment