質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Haskell

Haskellは高い機能性をもった関数型プログラミング言語で、他の手続き型プログラミング言語では難しいとされている関数でも容易に行うことができます。強い静的型付け、遅延評価などに対応しています。

Q&A

解決済

1回答

1305閲覧

Haskell stack ghc コンパイルで最適化オプションがエラーになる

mizoken001

総合スコア9

Haskell

Haskellは高い機能性をもった関数型プログラミング言語で、他の手続き型プログラミング言語では難しいとされている関数でも容易に行うことができます。強い静的型付け、遅延評価などに対応しています。

1グッド

0クリップ

投稿2020/05/21 08:12

Haskell stack ghc コンパイルで最適化オプションがエラーになる

Stack を使用して最適化オプションを指定すると
引数エラーとなります。
最適化オプションを指定しないとコンパイルできます。

最適化オプションの指定方法を教えて貰えませんか?

発生している問題・エラーメッセージ

$ stack ghc -O2 countdown.hs Invalid option `-O2' Usage: stack ghc [-- ARGS (e.g. stack runghc -- X.hs -o x)] [--[no-]ghc-package-path] [--[no-]stack-exe] [--package ARG] [--rts-options RTSFLAG] [--cwd DIR] [--setup-info-yaml URL] [--help] Run ghc

補足情報

$ stack --version
Version 2.1.3 x86_64
Compiled with:

  • Cabal-2.4.0.1
  • Glob-0.9.3
  • StateVar-1.1.1.1
  • aeson-1.3.1.1
  • aeson-compat-0.3.9
  • annotated-wl-pprint-0.7.0
  • ansi-terminal-0.9
  • ansi-wl-pprint-0.6.8.2
  • array-0.5.2.0
  • asn1-encoding-0.9.5
  • asn1-parse-0.9.4
  • asn1-types-0.3.2
  • async-2.2.1
  • attoparsec-0.13.2.2
  • attoparsec-iso8601-1.0.1.0
  • auto-update-0.1.4
  • base-4.11.1.0
  • base-compat-0.10.5
  • base-orphans-0.7
  • base-prelude-1.3
  • base16-bytestring-0.1.1.6
  • base64-bytestring-1.0.0.2
  • basement-0.0.8
  • bifunctors-5.5.3
  • binary-0.8.5.1
  • bitarray-0.0.1.1
  • blaze-builder-0.4.1.0
  • blaze-html-0.9.1.1
  • blaze-markup-0.8.2.2
  • byteable-0.1.1
  • bytestring-0.10.8.2
  • case-insensitive-1.2.0.11
  • cereal-0.5.7.0
  • clock-0.7.2
  • colour-2.3.4
  • comonad-5.0.4
  • conduit-1.3.1
  • conduit-combinators-1.3.0
  • conduit-extra-1.3.0
  • connection-0.2.8
  • containers-0.5.11.0
  • contravariant-1.4.1
  • cookie-0.4.4
  • cryptohash-sha256-0.11.101.0
  • cryptonite-0.25
  • cryptonite-conduit-0.2.2
  • data-default-class-0.1.2.0
  • deepseq-1.4.3.0
  • digest-0.0.1.2
  • directory-1.3.1.5
  • distributive-0.5.3
  • dlist-0.8.0.5
  • easy-file-0.2.2
  • echo-0.1.3
  • ed25519-0.0.5.0
  • either-5.0.1
  • exceptions-0.10.0
  • extra-1.6.14
  • fast-logger-2.4.11
  • file-embed-0.0.10.1
  • filelock-0.1.1.2
  • filepath-1.4.2
  • fsnotify-0.3.0.1
  • generic-deriving-1.12.2
  • ghc-boot-th-8.4.4
  • ghc-prim-0.5.2.0
  • githash-0.1.3.0
  • hackage-security-0.5.3.0
  • hashable-1.2.7.0
  • hfsevents-0.1.6
  • hi-file-parser-0.1.0.0
  • hourglass-0.2.12
  • hpack-0.31.2
  • hpc-0.6.0.3
  • http-api-data-0.3.8.1
  • http-client-0.5.14
  • http-client-tls-0.3.5.3
  • http-conduit-2.3.2
  • http-download-0.1.0.0
  • http-types-0.12.2
  • infer-license-0.2.0
  • integer-gmp-1.0.2.0
  • integer-logarithms-1.0.2.2
  • lifted-base-0.2.3.12
  • megaparsec-6.5.0
  • memory-0.14.18
  • microlens-0.4.9.1
  • microlens-th-0.4.2.3
  • mime-types-0.1.0.9
  • mintty-0.1.2
  • monad-control-1.0.2.3
  • monad-logger-0.3.30
  • monad-loops-0.4.3
  • mono-traversable-1.0.10.0
  • mtl-2.2.2
  • mustache-2.3.0
  • neat-interpolation-0.3.2.2
  • network-2.6.3.6
  • network-uri-2.6.1.0
  • old-locale-1.0.0.7
  • old-time-1.1.0.3
  • open-browser-0.2.1.0
  • optparse-applicative-0.14.3.0
  • optparse-simple-0.1.1.2
  • pantry-0.1.1.0
  • parsec-3.1.13.0
  • parser-combinators-1.0.0
  • path-0.6.1
  • path-io-1.3.3
  • path-pieces-0.2.1
  • pem-0.2.4
  • persistent-2.9.2
  • persistent-sqlite-2.9.3
  • persistent-template-2.5.4
  • pretty-1.1.3.6
  • primitive-0.6.3.0
  • process-1.6.3.0
  • profunctors-5.2.2
  • project-template-0.2.0.1
  • random-1.1
  • regex-applicative-0.3.3
  • regex-applicative-text-0.1.0.1
  • resource-pool-0.2.3.2
  • resourcet-1.2.2
  • retry-0.7.7.0
  • rio-0.1.10.0
  • rio-orphans-0.1.1.0
  • rio-prettyprint-0.1.0.0
  • rts-1.0
  • safe-0.3.17
  • safe-exceptions-0.1.7.0
  • scientific-0.3.6.2
  • semigroupoids-5.2.2
  • semigroups-0.18.5
  • silently-1.2.5
  • socks-0.5.6
  • split-0.2.3.3
  • stm-2.4.5.1
  • stm-chans-3.0.0.4
  • streaming-commons-0.2.1.0
  • syb-0.7
  • tagged-0.8.5
  • tar-0.5.1.0
  • tar-conduit-0.3.1
  • template-haskell-2.13.0.0
  • temporary-1.3
  • terminal-size-0.3.2.1
  • text-1.2.3.1
  • text-metrics-0.3.0
  • th-abstraction-0.2.10.0
  • th-expand-syns-0.4.4.0
  • th-lift-0.7.11
  • th-lift-instances-0.1.11
  • th-orphans-0.13.6
  • th-reify-many-0.1.8
  • th-utilities-0.2.0.1
  • time-1.8.0.2
  • time-locale-compat-0.1.1.5
  • tls-1.4.1
  • transformers-0.5.5.0
  • transformers-base-0.4.5.2
  • transformers-compat-0.6.2
  • typed-process-0.2.6.0
  • unicode-transforms-0.3.5
  • unix-2.7.2.2
  • unix-compat-0.5.1
  • unix-time-0.3.8
  • unliftio-0.2.9.0
  • unliftio-core-0.1.2.0
  • unordered-containers-0.2.9.0
  • uri-bytestring-0.3.2.1
  • uuid-types-1.0.3
  • vector-0.12.0.2
  • vector-algorithms-0.7.0.4
  • void-0.7.2
  • x509-1.7.5
  • x509-store-1.6.7
  • x509-system-1.6.6
  • x509-validation-1.6.11
  • yaml-0.10.4.0
  • zip-archive-0.3.3
  • zlib-0.6.2

Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically. If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

igrep👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

stack ghc -- -O2 countdown.hs というように、間に -- を挟んでください。
そのエラーは、ghcに与えたつもりの-O2オプションをstackコマンドが解釈してしまうことによるエラーです。
(他の多くのコマンドと同様に)--という特別な引数を与えると、それ以降のオプション(-で始まる引数)をstackが解釈しなくなります。

投稿2020/05/21 09:14

編集2020/05/21 09:26
igrep

総合スコア428

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mizoken001

2020/05/21 10:27

ありがとうございます。解決しました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問