Je travaille sur un projet qui s'appuie sur le modèle simple yesod. Je suis nouveau à la programmation fonctionnelle, haskell et Yesod, donc c'est probablement quelque chose d'évident pour quiconque ayant une expérience Yesod. En ce moment j'essaye de faire des appels d'API de github en utilisant ce library. Je rencontre des problèmes de type et je ne sais même pas comment commencer à les résoudre.Yesod: Utilisation de la bibliothèque Github API v3 pour Haskell
Vous pouvez trouver mon handler here.
Handler/Home.hs:43:19:
Couldn't match expected type ‘HandlerT
App IO (Either a0 GitHub.User)’
with actual type ‘GitHub.Request k0 GitHub.User’
In a stmt of a 'do' block:
possibleUser <- GitHub.userInfoForR "mike-burns"
In the expression:
do { maid <- maybeAuthId;
possibleUser <- GitHub.userInfoForR "mike-burns";
result <- either (("Error: " <>) . tshow) formatUser possibleUser;
defaultLayout
(do { (asWidgetT GHC.Base.. toWidget)
((blaze-markup-0.7.1.1:Text.Blaze.Internal.preEscapedText
GHC.Base.. Data.Text.pack)
"<p>Your current auth ID: ");
(asWidgetT GHC.Base.. toWidget) (toHtml (show maid));
(asWidgetT GHC.Base.. toWidget)
((blaze-markup-0.7.1.1:Text.Blaze.Internal.preEscapedText
GHC.Base.. Data.Text.pack)
"</p>\n");
.... }) }
Handler/Home.hs:44:38:
Couldn't match type ‘Text’ with ‘HandlerT App IO a1’
Expected type: a0 -> HandlerT App IO a1
Actual type: a0 -> Text
In the second argument of ‘(.)’, namely ‘tshow’
In the first argument of ‘either’, namely
‘(("Error: " <>) . tshow)’
Handler/Home.hs:44:45:
Couldn't match type ‘Text’ with ‘HandlerT App IO a1’
Expected type: GitHub.User -> HandlerT App IO a1
Actual type: GitHub.User -> Text
In the second argument of ‘either’, namely ‘formatUser’
In a stmt of a 'do' block:
result <- either (("Error: " <>) . tshow) formatUser possibleUser
au lieu de 'possibleUser <- GitHub.userInfoForR "mike-brûlures"' 'écrire laisser possibleUser = GitHub.userInfoForR "mike-brûlures"' – arrowd
Salut arrowd. Cela supprime en effet les erreurs relatives à la ligne "possibleUser", mais l'utilisation de cette variable dans la ligne de résultat "suivante provoque l'erreur suivante (peut-être faut-il la structurer avec un 'in'?):' Handler/Home.hs : 49: 59: ' ' Impossible de correspondre au type attendu 'Soit a0 GitHub.User'' 'avec le type réel' GitHub.Request k0 GitHub.User'' ' Dans le troisième argument de 'soit', à savoir ' Dans l'expression: ' ' soit (("Erreur:" <>). tshow) formatUser possibleUser' – StarStuffSteve