0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

utopでDeferredの中身が見えない場合の対処法

0
Posted at

結論から言うとOCamlのバージョンを上げてやることで解決しました。

問題

本来utopで'a Deferred.t型の値を評価すると計算結果('a)を表示してくれるのですが、手元のutop 2.0.1 + OCaml 4.02.3では次のように表示されました。

utop # let three = Async.Std.return 3;; 
val three : int Deferred.t = <abstr>
utop # three;;
- : int Deferred.t = <abstr>      

対処法

opam switchでOCamlのバージョンを変更(4.02.3 -> 4.03.0)します。

$ opam switch 4.03.0

基本的にはこれで終わりですが、モジュール等はインストールしなおす必要があります。

$ eval `opam config env`
$ opam install utop core async

確認

utop # let three = Async.Std.return 3;; 
Characters 12-28:
Warning 3: deprecated: module Async.Std
[since 2017-02] use Async. The Std sub-module is no longer needed
val three : int Async.Deferred.t = <abstr>
utop # three;;
- : int = 3

ちゃんとDeferredの中身が分かるようになりました。

ちなみにutopのバージョンが原因という場合もあるようです。
Utop not waiting for Deferred to determine then displaying result · Issue #137 · diml/utop
Async.Std.Deferred.t not automatically resolving · Issue #219 · diml/utop

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?