私はoptparse-genericでこのページを見ています。Haskell Optarse TypeOperatorsとDataKindsで失敗する一般的な例
$ stack install optparse-generic-1.1.4
optparse-generic-1.1.4: download
optparse-generic-1.1.4: configure
optparse-generic-1.1.4: build
optparse-generic-1.1.4: copy/register
私は与えられたとおりに、このサンプルコードを実行しようとすると::
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
import Options.Generic
data Example = Example
{ foo :: Int <?> "Documentation for the foo flag"
, bar :: Double <?> "Documentation for the bar flag"
} deriving (Generic, Show)
を私が手:
<interactive>:10:14-56: error:
Illegal operator ‘<?>’ in type ‘Int <?> "Documentation for the foo flag"’
Use TypeOperators to allow operators in types
<interactive>:10:25-56: error:
Illegal type: ‘"Documentation for the foo flag"’
Perhaps you intended to use DataKinds
<interactive>:11:14-56: error:
Illegal operator ‘<?>’ in type ‘Double <?> "Documentation for the bar flag"’
Use TypeOperators to allow operators in types
<interactive>:11:25-56: error:
Illegal type: ‘"Documentation for the bar flag"’
Perhaps you intended to use DataKinds
λ>
あなたが見ることができるようにoptparseはこのバージョンの
私はDataKindsとTypeOperatorsの両方を有効にしています。ここで起こっていることをどのようにデバッグできますか?
どのようにファイルをロードしていますか?エラーメッセージの ''部分は、あなたがGHCIセッションに直接サンプルを入力していると思います。拡張機能がオンになっていますか? (この例は、私の最後のファイルからロードされたときに正常に動作します) –
adamse
'data Example'の定義の上にある部分を含むファイルをロードしました。 ghciで2番目の部分を入力しました。 – Mittenchops
すべてがファイル内にある場合は、すべて問題ありません。しかし、ghciでこれらのデータ型をテストし定義することはできませんか? – Mittenchops