我正在尝试installed application credentials的示例
gogol package中。

这是示例(仅从已安装的应用程序凭证页面复制):

{-# LANGUAGE ScopedTypeVariables #-}
import Data.Proxy     (Proxy (..))
import Data.Text      as T
import Data.Text.IO   as T
import System.Exit    (exitFailure)
import System.Info    (os)
import System.Process (rawSystem)
redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s)
redirectPrompt c p = do
    let url = formURL c p
    T.putStrLn $ "Opening URL " `T.append` url
    _ <- case os of
        "darwin" -> rawSystem "open"     [unpack url]
        "linux"  -> rawSystem "xdg-open" [unpack url]
    _        -> T.putStrLn "Unsupported OS" >> exitFailure
    T.putStrLn "Please input the authorisation code: "
    OAuthCode <$> T.getLine

在编译代码时,出现以下错误:
Illegal kind signature: ‘s’
  Perhaps you intended to use KindSignatures
In the type signature for ‘redirectPrompt’

Illegal kind: ‘[Symbol]’ Perhaps you intended to use DataKinds

所以我在代码中添加了这两行:
{-# LANGUAGE KindSignatures    #-}
{-# LANGUAGE DataKinds         #-}

然后,再次编译。它显示以下错误消息:
• Couldn't match kind ‘[Symbol]’ with ‘*’
  When matching the kind of ‘proxy’
• In the second argument of ‘formURL’, namely ‘p’
  In the expression: formURL c p
  In an equation for ‘url’: url = formURL c p
• Relevant bindings include
    p :: proxy s (bound at app/Main.hs:36:18)
    redirectPrompt :: OAuthClient -> proxy s -> IO (OAuthCode s)
      (bound at app/Main.hs:36:1)

我不知道为什么会出错。.p的类型看起来与formURL一样。
-- https://hackage.haskell.org/package/gogol-0.1.1/docs/Network-Google-Auth.html#v:formURL
formURL :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> Text

我会误会吗?

更新了

我使用的版本是lts-7.19。
从lts-7.19更改为lts-8.0后,它可以工作。

lts-7.19的ghc版本是8.0.1。
lts-8.0的是8.0.2。
这是ghc-8.0.2-released的一些注释。

最佳答案

lts-8.0.cabal中的正确依赖项一起使用

 build-depends:    base
                 , gogol
                 , gogol-core
                 , process
                 , text

您需要在其中定义了{-# LANGUAGE OverloadedStrings #-}import GHC.TypeLitsSymbol
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE KindSignatures    #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds         #-}

module Main where

import Network.Google.Auth
import GHC.TypeLits

import Data.Proxy     (Proxy (..))
import Data.Text      as T
import Data.Text.IO   as T
import System.Exit    (exitFailure)
import System.Info    (os)
import System.Process (rawSystem)

redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s)
redirectPrompt c p = do
 let url = formURL c p
 T.putStrLn $ "Opening URL " `T.append` url
  _ <- case os of
        "darwin" -> rawSystem "open"     [unpack url]
        "linux"  -> rawSystem "xdg-open" [unpack url]
        _        -> T.putStrLn "Unsupported OS" >> exitFailure
T.putStrLn "Please input the authorisation code: "
OAuthCode <$> T.getLine

main = print "working"

10-06 02:44